Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 01-20-2022, 05:13 AM
Matt C's Avatar
Matt C Matt C is offline "BeforePrint" VBA causes only first worksheet of grouped worksheets to be printed Windows 10 "BeforePrint" VBA causes only first worksheet of grouped worksheets to be printed Office 97-2003
Advanced Beginner
"BeforePrint" VBA causes only first worksheet of grouped worksheets to be printed
 
Join Date: May 2021
Location: London, UK
Posts: 30
Matt C is on a distinguished road
Question "BeforePrint" VBA causes only first worksheet of grouped worksheets to be printed

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
Reply With Quote
Reply

Thread Tools
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
Excel 2003: VBA "Function" causes "#VALUE!" errors after running "insert/delete row" custom macro Matt C Excel Programming 2 01-08-2022 06:03 AM
"Printed By" in Word Document Lacarrye Word 5 12-03-2016 07:25 PM
Grouped Shapes > "Save Picture As" JamesEddy Word 0 10-29-2014 01:29 PM
Unable to "Shift cells down" on unprotected area in a protected worksheet ricky0309 Excel 0 08-14-2014 01:51 AM
"BeforePrint" VBA causes only first worksheet of grouped worksheets to be printed "Auto-populating" data-worksheet to worksheet. meggenm Excel 4 02-04-2012 02:04 AM

Other Forums: Access Forums

All times are GMT -7. The time now is 08:53 AM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2024 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft