Hi folks.
I'm trying to suss out some VBA which automatically populates/updates the header/footer areas at the "before print" stage for Sheet 3 of a three-sheet workbook, of which Sheets 2 and 3 must be printed together.
Sheet 3 draws header/footer info from some defined cells in Sheet 1. Sheet 1 and 2's headers/footers are left blank. Sheets 2 and 3 must be printed together but when I group them for printing, only Sheet 2 is printed.
I also need to future-proof it for any new worksheets that are added later, which should also contain the same header/footer info and print when grouped with Sheets 2 and 3.
Can anyone help?
Quote:
Private Sub Workbook_BeforePrint(Cancel As Boolean)
Application.ScreenUpdating = False
With Sheets(3)
'Left Header
.PageSetup.LeftHeader = Sheets(1).Range("HeaderLeft").Value
'Centre Header
.PageSetup.CenterHeader = Sheets(1).Range("HeaderCentre").Value
'Left Footer
.PageSetup.LeftFooter = Sheets(1).Range("FooterLeft").Value
'Centre Footer
.PageSetup.CenterFooter = Sheets(1).Range("FooterCentre").Value
'Right Footer
.PageSetup.RightFooter = Sheets(1).Range("FooterRight").Value
End With
Application.ScreenUpdating = True
End Sub
|