D
DavidW
I have a spreadsheet with a list of rep #'s followed by data for each
rep. I've written a macro to create page breaks when the rep # changes.
Is there a way to have the footer for each rep set to page 1 and then
have each page incremented by 1 for that rep? For example, I might have
a list of three reps. The first rep has two pages, the second has one,
the third has five. Can I code the macro to insert footers of pages 1 &
2 for rep 1, page 1 for rep 2, and pages 1, 2, 3, 4, & 5 for rep3?
The macro below works for the page breaks.
Thanks.
Code:
--------------------
Dim NumRows As Long
Dim iRow As Long
Dim FirstRow As Long
Dim LastRow As Long
NumRows = Range("A65536").End(xlUp).Row 'get the row count
With ActiveSheet
FirstRow = 8
LastRow = NumRows
For iRow = FirstRow To LastRow
If Worksheets("Report").Cells(iRow, "C").Value _
<> Worksheets("Report").Cells(iRow + 1, "C").Value _
And Worksheets("Report").Cells(iRow + 1, "C").Value <> 0 Then
'insert page break when rep# changes and the cell is not blank
Worksheets("Report").HPageBreaks.Add Before:=Worksheets("Report").Cells(iRow + 1, "A")
Else
'do nothing
End If
Next iRow
End With
rep. I've written a macro to create page breaks when the rep # changes.
Is there a way to have the footer for each rep set to page 1 and then
have each page incremented by 1 for that rep? For example, I might have
a list of three reps. The first rep has two pages, the second has one,
the third has five. Can I code the macro to insert footers of pages 1 &
2 for rep 1, page 1 for rep 2, and pages 1, 2, 3, 4, & 5 for rep3?
The macro below works for the page breaks.
Thanks.
Code:
--------------------
Dim NumRows As Long
Dim iRow As Long
Dim FirstRow As Long
Dim LastRow As Long
NumRows = Range("A65536").End(xlUp).Row 'get the row count
With ActiveSheet
FirstRow = 8
LastRow = NumRows
For iRow = FirstRow To LastRow
If Worksheets("Report").Cells(iRow, "C").Value _
<> Worksheets("Report").Cells(iRow + 1, "C").Value _
And Worksheets("Report").Cells(iRow + 1, "C").Value <> 0 Then
'insert page break when rep# changes and the cell is not blank
Worksheets("Report").HPageBreaks.Add Before:=Worksheets("Report").Cells(iRow + 1, "A")
Else
'do nothing
End If
Next iRow
End With