copying header to all worksheets

Chevroyd

New Member
Joined
Jul 25, 2002
Messages
11
Hi there,
I have an Excel file containing 10 worksheets.
How can I set up worksheet no1 header info copied automatically into worksheets 2 through to 10 so that whatever I type in No 1 header will copy through to the rest.
Is this possible?
Thanks
RC
 

Excel Facts

What is the last column in Excel?
Excel columns run from A to Z, AA to AZ, AAA to XFD. The last column is XFD.
Hi,

Dont you just need, in sheets 2 to 10 the formula:

Cell A1: =Sheet1!A1

and copy this formula across the row.

HTH

Alan
 
Upvote 0
Hi Chevroyd

You can add a header to a group of sheets in the same workbook by selecting File -> Page setup and choosing the Header/ Footer tab. Then choose the Custom Header button and paste your header into the spaces available.

There are a bunch of formatting codes available to you when you create a header. Look in the "Formatting Codes for Headers and Footers" in the Excel Help.

anvil19
:eek:
 
Upvote 0
al_b_cnu ("In all those old familiar places - That this heart of mine embraces"- da de da - if that rings a bell you are a bit over the hill - like me!)
and
anvil19

thanks board masters and regulars

thanks for the reply - but this is not the answer to my problem
I am convinced I have set up a HEADER or FOOTER for a bunch of worksheets in the same file before without having to literally copy the stuff into each sheet's header - (thats why I ask the question) - so I think its possible, but maybe my advanced years ....have distorted my memory banks...anyway..

(al_b_cnu) - I am not simply trying to refer the cell a1 in worksheets 2 to 10 to cell a1 in worksheet 1 - thats easy - its the HEADER or FOOTER info i want to behave in the same way - see?

(anvil19) - I am not simply trying to set up the header or footer -
been there -

Its the automation bit Im after - if it exists.
RC
 
Upvote 0
Howdee Chevroyd

Yes, I do recognise the ditty, and I'm sorry I didn't get the gist of your problem before (not the being over the hill problem, it's too late for that)

This is a couple of pieces of code from the 12 October 2002 edition of ExcelTips so with all due consideration to them try it and see if it helps. I changed the first bit of code to just do headers.

The following two macros can be used to copy headers and footers
in one simple step.

All you need to do is display the source worksheet and use the GetHeaders macro. This macro copies the header and footer information to string variables. You can then display, in turn, each worksheet that you want to have the same header and footer and run the DoHeaders macro.

Code:
Option Explicit
      
      Dim strHeadLeft As String
      Dim strHeadCenter As String
      Dim strHeadRight As String
      Dim bGotHeaders As Boolean
      
      Sub GetHeaders()
          With ActiveSheet.PageSetup
              strHeadLeft = .LeftHeader
              strHeadCenter = .CenterHeader
              strHeadRight = .RightHeader
              bGotHeaders = True
          End With
      End Sub
      
      Sub DoHeaders()
          If bGotHeaders Then
              With ActiveSheet.PageSetup
                  .LeftHeader = strHeadLeft
                  .CenterHeader = strHeadCenter
                  .RightHeader = strHeadRight
              End With
          Else
              MsgBox "Select the sheet with the
 headers you want to copy," _
                  & vbCrLf & "then run 'GetHeaders'",
 vbExclamation, _
                  "No Headers In Memory"
          End If
      End Sub

You could even assign the macros to toolbar buttons, if desired, which can make them even handier for copying headers.

If you have quite a few worksheets and workbooks into which you want
the headers and footers copied, there is a different macro approach
you can use. The following macro will copy the headers and footers
from the active worksheet to all other worksheets in all other open
workbooks.

Code:
Sub CopyHeaderFooter()
         Dim PS As PageSetup, WB As Workbook, WS As
 Worksheet
         Set PS = ActiveSheet.PageSetup
         For Each WB In Workbooks
           For Each WS In WB.Worksheets
             With WS.PageSetup
               .LeftHeader = PS.LeftHeader
               .CenterHeader = PS.CenterHeader
               .RightHeader = PS.RightHeader
               .LeftFooter = PS.LeftFooter
               .CenterFooter = PS.CenterFooter
               .RightFooter = PS.RightFooter
             End With
           Next
         Next
      End Sub

In other words, if you want to copy headers and footers from the
current worksheet to 150 other worksheets spread across 15 different
workbooks, all you need to do is open the 15 workbooks at the same
time, display the source worksheet, and run the macro


Good Luck

anvil19
:eek:
 
Upvote 0
OP,
Just go to the page with the existing header (the one you want to dispaly elsewhere). Press page setup and then OK.
Now, choose all the sheets you want your header copied into and..
press F4.
OK?
Cheers.
 
Upvote 0
Thanks Lucky Charm

- thats it ! - blow me down dead easy! I knew Id done it before)

I still have to do the macro bit anvil19 - have to get out my tutor sometime!
Thanks anyway
RC
 
Upvote 0

Forum statistics

Threads
1,214,389
Messages
6,119,232
Members
448,879
Latest member
VanGirl

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top