how to insertnew worksheet page

N

nellellen

I have a 4 column worksheet sorted by column A (product name). there are
3000 records in the worksheet. I need to create a page break based on a
change of the value in Collumn A. The ultimate destination of the results
will be insertion into a word document with a page break between each
separate "table".

any assistance onhow to achieve the above is greatly appreciated. My skill
level in excel is moderate beginner...

thank you - Ellen
 
G

Gord Dibben

Sub Insert_PBreak()
Dim OldVal As String
Dim rng As Range
OldVal = Range("A1")
For Each rng In Range("A1:A3000")
If rng.text <> OldVal Then
rng.PageBreak = xlPageBreakManual
OldVal = rng.text
End If
Next rng
End Sub

Note............with 3000 cells to look at, will take a while because
pagebreak insertion is a slow process.


Gord Dibben MS Excel MVP
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top