Richie
Many thanks - like the code and understand most of it. I've tried to amend it to suit but I'm getting a bit stuck. Also I don't quite follow the show Dialog box bit - I have to click on 'OK' to clear. This is what I've got so far - I've added a loop to look at the ID numbers in Col A and skip if they are the same - seems to be OK. My main problem is trying to print the correct pages with the correct header. I think I'm nearly there but I'm now getting errors like 'Block If without End If' and 'Invalid Next Control variable reference'. I can't seem to work this out and would appreciate any help.
Thanks
Sub CustomHeaderFooterV3()
Dim ws As Worksheet
Dim strLH As String, strCH As String, strRH As String
Dim strLF As String, strCF As String, strRF As String
Dim rngCell As Range, rngData As Range, rngAdd As Range
Dim i As Integer, x As Long
With Application
.ScreenUpdating = False
.Calculation = xlCalculationManual
End With
Set rngAdd = Range("BranchAddress")
'named range
x = Worksheets("Test Print").HPageBreaks.Count
With Worksheets("Test Print")
Set rngData = .Range("A6:A" & .Cells(.Rows.Count, "A").End(xlUp).Row) _
.SpecialCells(xlCellTypeConstants, xlNumbers)
For Each rngCell In rngData
If rngCell.Value <> rngCell.Offset(-2, 0).Value Then
strLH = "&B" & "&16" & Application.WorksheetFunction.VLookup(rngCell.Value, rngAdd, 2) & " " _
& Application.WorksheetFunction.VLookup(rngCell.Value, rngAdd, 1)
' For Each ws In ThisWorkbook.Worksheets
' ws.Activate
Application.SendKeys "{ENTER}", False
Application.Dialogs(xlDialogPageSetup).Show _
Arg1:=strLH
' Next
For i = 1 To x
Worksheets("Test Print").Activate
ActiveSheet.PrintOut from:=i, To:=x - (x - i), copies:=1
'End If
Next rngCell
Next i
End With
With Application
.ScreenUpdating = True
.Calculation = xlCalculationAutomatic
End With
End Sub