View Full Version : Solved: Headers & Footers - Multiple Sheets
Hoopsah
07-07-2008, 05:48 AM
Hi,
I have a worksheet that has over 30 tabs on it.
Is there a way that I can create a Header and footer and it would update all the tabs with the same details?
Thanks for any help
Bob Phillips
07-07-2008, 05:57 AM
Dim i As Long
For i = 2 To Worksheets.Count
Worksheets(i).PageSetup.LeftHeader = Worksheets(1).PageSetup.LeftHeader
Next i
Hoopsah
07-07-2008, 06:13 AM
Hi Bob,
sorry to sound a bit dim here.
But, where would I put that code and would I have to make any amendments to it?
Cheers Bob
Gerry
Bob Phillips
07-07-2008, 06:31 AM
I created it as a once-off, as I assumed that was what you wanted. Just drop it into a macro and run that.
Hoopsah
07-07-2008, 06:55 AM
Hi Bob,
Once again this works a treat.
I created a macro and amended a the lines to copy the other sections of both the headers and the footers and ran the macro - works like a charm.
Just for reference my final code was:
Sub Macro1()
'
' Macro1 Macro
' Macro recorded 07/07/2008 by Gerry McNally
'
Dim i As Long
For i = 2 To Worksheets.Count
Worksheets(i).PageSetup.LeftHeader = Worksheets(1).PageSetup.LeftHeader
Worksheets(i).PageSetup.CenterHeader = Worksheets(1).PageSetup.CenterHeader
Worksheets(i).PageSetup.RightHeader = Worksheets(1).PageSetup.RightHeader
Worksheets(i).PageSetup.LeftFooter = Worksheets(1).PageSetup.LeftFooter
Worksheets(i).PageSetup.CenterFooter = Worksheets(1).PageSetup.CenterFooter
Worksheets(i).PageSetup.RightFooter = Worksheets(1).PageSetup.RightFooter
Next i
'
End Sub
Marking this as solved.
Thanks Bob :bow:
Bob Phillips
07-07-2008, 07:54 AM
Pleasure.
Just for tidiness (I am a Virgo!)
Sub Macro1()
'
' Macro1 Macro
' Macro recorded 07/07/2008 by Gerry McNally
'
Dim i As Long
With Worksheets(1).PageSetup
For i = 2 To Worksheets.Count
Worksheets(i).PageSetup.LeftHeader = .LeftHeader
Worksheets(i).PageSetup.CenterHeader = .CenterHeader
Worksheets(i).PageSetup.RightHeader = .RightHeader
Worksheets(i).PageSetup.LeftFooter = .LeftFooter
Worksheets(i).PageSetup.CenterFooter = .CenterFooter
Worksheets(i).PageSetup.RightFooter = .RightFooter
Next i
End With
End Sub
Hoopsah
07-08-2008, 01:58 AM
Much better,
thank you.
:thumb
Powered by vBulletin® Version 4.2.5 Copyright © 2024 vBulletin Solutions Inc. All rights reserved.