I have a spreadsheet with warehouse locations in the first column in an Excel worksheet. For each location there can be one or more items. Items are listed in the second column. I need to print out all of this information, with each location on a different page. I have used the following Macro to achieve this:
Sub pagebrk()
col = 1
LastRw = ActiveSheet.UsedRange.Rows.Count
For x = 2 To LastRw
If Cells(x, col) <> Cells(x - 1, col) Then
ActiveWindow.SelectedSheets.HPageBreaks.Add Before:=Cells(x, col)
End If
Next
End Sub
If possible, I would like to put the location as the header on each page that is printed out. I have tried to find a suitable macro to do this, but so far have failed.
Any advice would be much appreciated.
Cheers,
NEM.
Sub pagebrk()
col = 1
LastRw = ActiveSheet.UsedRange.Rows.Count
For x = 2 To LastRw
If Cells(x, col) <> Cells(x - 1, col) Then
ActiveWindow.SelectedSheets.HPageBreaks.Add Before:=Cells(x, col)
End If
Next
End Sub
If possible, I would like to put the location as the header on each page that is printed out. I have tried to find a suitable macro to do this, but so far have failed.
Any advice would be much appreciated.
Cheers,
NEM.