Please Note: This article is written for users of the following Microsoft Excel versions: 2007, 2010, 2013, 2016, 2019, Excel in Microsoft 365, and 2021. If you are using an earlier version (Excel 2003 or earlier), this tip may not work for you. For a version of this tip written specifically for earlier versions of Excel, click here: Copying Headers and Footers.

Copying Headers and Footers

Written by Allen Wyatt (last updated March 2, 2024)
This tip applies to Excel 2007, 2010, 2013, 2016, 2019, Excel in Microsoft 365, and 2021


2

Excel allows you to specify headers and footers for your worksheets. You may want to copy these headers and footers from one worksheet to another. Doing so within a workbook is relatively easy, but doing so from one workbook to another can be more daunting.

If the header and footer is one you use quite a bit in new workbooks, and your main concern is to have the header and footer available in those new workbooks (not in existing workbooks), then the best approach would be to create a template workbook. Just set up a workbook as desired, including the specification of headers and footers. Then, save the workbook as an Excel template (XLTX format). You can then create your workbooks based on this template and it will have the headers and footers you desire.

One way to copy headers and footers from a worksheet in one workbook to a worksheet in another is to use the traditional editing methods of copying and pasting. In other words, you can select the header material you want to copy, press Ctrl+C, display the header in the target worksheet, and then press Ctrl+V. The drawback to this approach is that it can involve quite a few steps. After all, there are three sections (left, center, and right) for each header and three for each footer. This means that you must do six copy and paste operations to copy the complete header and footer.

Another way to copy headers and footers from one workbook to another involves the use of native Excel commands to make copies of worksheets. Follow these steps:

  1. Open the target workbook; the one to which you want the headers and footers copied.
  2. Open the workbook that is the source of your header and footer, and make sure the desired worksheet is displayed.
  3. Display the Home tab of the ribbon.
  4. Click the Format tool (in the Cells group) and then choose Move or Copy Sheet. Excel displays the Move or Copy dialog box. (See Figure 1.)
  5. Figure 1. The Move or Copy dialog box.

  6. Using the To Book drop-down list, select the target workbook you opened in step 1.
  7. Using the Before Sheet area, indicate where you want the sheet copied.
  8. Make sure the Create a Copy check box is selected.
  9. Click on OK. The worksheet is copied to the target workbook.
  10. Close the source workbook from step 2.
  11. In the target workbook, display the worksheet you just copied.
  12. In the tab area at the bottom of the window, right-click and choose Select All Sheets. All the worksheets are now selected.
  13. Display the Page Layout tab of the ribbon.
  14. Click the small icon at the lower-right corner of the Page Setup group. Excel displays the Page Setup dialog box.
  15. Make sure the Header/Footer tab is selected. (See Figure 2.)
  16. Figure 2. The Header/Footer tab of the Page Setup dialog box.

  17. Using the Header and Footer drop-down lists, select the header and footer used in the worksheet you just copied.
  18. Click on OK.
  19. Delete the worksheet you copied in steps 1 through 8.

What you essentially did is to copy the worksheet containing the header and footer you desired, then you copied that header and footer to other worksheets in the workbook, then you deleted the original worksheet.

While these steps work fine, they can be tedious if you need to copy headers and footers to a number of different workbooks. In this case, using a macro to do the copying is the saner approach. 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.

Option Explicit

Dim strHeadLeft As String
Dim strHeadCenter As String
Dim strHeadRight As String
Dim strFootLeft As String
Dim strFootCenter As String
Dim strFootRight As String
Dim bGotHeaders As Boolean

Sub GetHeaders()
    With ActiveSheet.PageSetup
        strHeadLeft = .LeftHeader
        strHeadCenter = .CenterHeader
        strHeadRight = .RightHeader
        strFootLeft = .LeftFooter
        strFootCenter = .CenterFooter
        strFootRight = .RightFooter
        bGotHeaders = True
    End With
End Sub
Sub DoHeaders()
    If bGotHeaders Then
        With ActiveSheet.PageSetup
            .LeftHeader = strHeadLeft
            .CenterHeader = strHeadCenter
            .RightHeader = strHeadRight
            .LeftFooter = strFootLeft
            .CenterFooter = strFootCenter
            .RightFooter = strFootRight
        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 or to the Quick Access toolbar, if desired, which can make them even handier for copying headers and footers.

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.

Sub CopyHeaderFooter()
    Dim PS As PageSetup
    Dim WB As Workbook
    Dim 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.

Note:

If you would like to know how to use the macros described on this page (or on any other page on the ExcelTips sites), I've prepared a special page that includes helpful information. Click here to open that special page in a new browser tab.

ExcelTips is your source for cost-effective Microsoft Excel training. This tip (12519) applies to Microsoft Excel 2007, 2010, 2013, 2016, 2019, Excel in Microsoft 365, and 2021. You can find a version of this tip for the older menu interface of Excel here: Copying Headers and Footers.

Author Bio

Allen Wyatt

With more than 50 non-fiction books and numerous magazine articles to his credit, Allen Wyatt is an internationally recognized author. He is president of Sharon Parq Associates, a computer and publishing services company. ...

MORE FROM ALLEN

Hiding Errors

If you find the green and red squiggly underlines that Word adds to your document distracting, you might want a quick way ...

Discover More

Using Go To to Jump to a Chart Sheet

Create a chart on its own worksheet, and you can display it by simply clicking the tab at the bottom of the Excel work ...

Discover More

Determining the MAC Address for a Network Device

MAC addresses are used to uniquely identify devices attached to your network. If you need to figure out what MAC address ...

Discover More

Excel Smarts for Beginners! Featuring the friendly and trusted For Dummies style, this popular guide shows beginners how to get up and running with Excel while also helping more experienced users get comfortable with the newest features. Check out Excel 2013 For Dummies today!

More ExcelTips (ribbon)

Adding Last-Row Data to a Page Footer

If you want to modify information that appears in the footer of a worksheet printout, on a page-by-page basis, you can ...

Discover More

Specifying Date Formats in Headers

Don't like the default date format used by Excel when you place the date in a header or footer? You can use a macro to ...

Discover More

Using X of Y in a Page Footer

If you want your printed worksheet to include page numbers, adding them is relatively easy. This tip shows two ways that ...

Discover More
Subscribe

FREE SERVICE: Get tips like this every week in ExcelTips, a free productivity newsletter. Enter your address and click "Subscribe."

View most recent newsletter.

Comments

If you would like to add an image to your comment (not an avatar, but an image to help in making the point of your comment), include the characters [{fig}] (all 7 characters, in the sequence shown) in your comment text. You’ll be prompted to upload your image when you submit the comment. Maximum image size is 6Mpixels. Images larger than 600px wide or 1000px tall will be reduced. Up to three images may be included in a comment. All images are subject to review. Commenting privileges may be curtailed if inappropriate images are posted.

What is 4 + 5?

2024-03-04 20:28:35

Tomek

@J. Woolley: Nice formatting of the code. I think everyone will appreciate it.


2024-03-03 11:14:08

J. Woolley

The Tip's macros neglect PageSetup's DifferentFirstPageHeaderFooter and OddAndEvenPagesHeaderFooter properties. CopyHeaderFooter also ignores Chart sheets and unnecessarily copies the active sheet's headers and footers to itself. Here is an improved version of CopyHeaderFooter:

Sub CopyHeaderFooter2() 'ignore HeaderPictures and FooterPictures
    Dim PS As PageSetup, WB As Workbook, Sheet As Object
    Dim FP As Object, EP As Object, bFP As Boolean, bEP As Boolean
    Set PS = ActiveSheet.PageSetup
    With PS
        bFP = .DifferentFirstPageHeaderFooter
        If bFP Then Set FP = .FirstPage
        bEP = .OddAndEvenPagesHeaderFooter
        If bEP Then Set EP = .EvenPage
    End With
    For Each WB In Workbooks
        For Each Sheet In WB.Sheets
            If Sheet Is ActiveSheet Then Exit For
            With Sheet.PageSetup
                .LeftHeader = PS.LeftHeader
                .CenterHeader = PS.CenterHeader
                .RightHeader = PS.RightHeader
                .LeftFooter = PS.LeftFooter
                .CenterFooter = PS.CenterFooter
                .RightFooter = PS.RightFooter
                .DifferentFirstPageHeaderFooter = bFP
                .OddAndEvenPagesHeaderFooter = bEP
                If bFP Then
                    With .FirstPage
                        .LeftHeader.Text = FP.LeftHeader.Text
                        .CenterHeader.Text = FP.CenterHeader.Text
                        .RightHeader.Text = FP.RightHeader.Text
                        .LeftFooter.Text = FP.LeftFooter.Text
                        .CenterFooter.Text = FP.CenterFooter.Text
                        .RightFooter.Text = FP.RightFooter.Text
                    End With
                End If
                If bEP Then
                    With .EvenPage
                        .LeftHeader.Text = EP.LeftHeader.Text
                        .CenterHeader.Text = EP.CenterHeader.Text
                        .RightHeader.Text = EP.RightHeader.Text
                        .LeftFooter.Text = EP.LeftFooter.Text
                        .CenterFooter.Text = EP.CenterFooter.Text
                        .RightFooter.Text = EP.RightFooter.Text
                    End With
                End If
            End With
        Next Sheet
    Next WB
    MsgBox "Headers and footers were copied from the active sheet " _
        & "to all sheets of all open workbooks.", vbInformation
End Sub


This Site

Got a version of Excel that uses the ribbon interface (Excel 2007 or later)? This site is for you! If you use an earlier version of Excel, visit our ExcelTips site focusing on the menu interface.

Newest Tips
Subscribe

FREE SERVICE: Get tips like this every week in ExcelTips, a free productivity newsletter. Enter your address and click "Subscribe."

(Your e-mail address is not shared with anyone, ever.)

View the most recent newsletter.