Please Note: This article is written for users of the following Microsoft Excel versions: 2007, 2010, 2013, 2016, 2019, and Excel in Microsoft 365. 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: Find and Replace in Headers.

Find and Replace in Headers

Written by Allen Wyatt (last updated January 17, 2023)
This tip applies to Excel 2007, 2010, 2013, 2016, 2019, and Excel in Microsoft 365


One of the very useful tools provided in Excel is Find and Replace, which allows you to locate and change information stored in cells. One place that Find and Replace won't work, however, is with information stored in headers or footers for your worksheets.

The only way to handle the finding and replacing of information in a header or footer is to use a macro. It is a rather trivial task to access what is stored in the various parts of the header and footer, check them for what you want to find, and then replace it with some new text. The following macro provides an example.

Sub FnR_HF()
    Dim sWhat As String, sReplacment As String
    Const csTITLE As String = "Find and Replace"

    sWhat = InputBox("Replace what", csTITLE)
    If Len(sWhat) = 0 Then Exit Sub
    sReplacment = InputBox("With what", csTITLE)

    With ActiveSheet.PageSetup
        ' Substitute Header/Footer values
        .LeftHeader = Application.WorksheetFunction.Substitute( _
                      .LeftHeader, sWhat, sReplacment)
        .CenterHeader = Application.WorksheetFunction.Substitute( _
                        .CenterHeader, sWhat, sReplacment)
        .RightHeader = Application.WorksheetFunction.Substitute( _
                       .RightHeader, sWhat, sReplacment)
        .LeftFooter = Application.WorksheetFunction.Substitute( _
                      .LeftFooter, sWhat, sReplacment)
        .CenterFooter = Application.WorksheetFunction.Substitute( _
                        .CenterFooter, sWhat, sReplacment)
        .RightFooter = Application.WorksheetFunction.Substitute( _
                       .RightFooter, sWhat, sReplacment)
    End With
End Sub

Note how the macro does the replacements in all three parts of the header and all three parts of the footer.

If you prefer to not use your own macro, or if you want a more full-featured Find and Replace for Excel, you might consider the free FlexFind add-in from Excel MVP Jan Karel Pieterse:

http://www.jkp-ads.com/officemarketplaceff-en.asp

This add in searches regularly, but also searches in lots of other areas including headers and footers.

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 (3388) applies to Microsoft Excel 2007, 2010, 2013, 2016, 2019, and Excel in Microsoft 365. You can find a version of this tip for the older menu interface of Excel here: Find and Replace in Headers.

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

Using a Progress Indicator in Macros

A few tips on adding a progress indicator that runs during long macro calculations.

Discover More

Locking Callouts to a Graph Location

If you add callouts using the drawing tools in Excel, you may have noticed that they don't always stay where you expect ...

Discover More

Accepting All Formatting Changes

Tired of wading through a bunch of formatting changes when you have Track Changes turned on? Here's how to accept all ...

Discover More

Comprehensive VBA Guide Visual Basic for Applications (VBA) is the language used for writing macros in all Office programs. This complete guide shows both professionals and novices how to master VBA in order to customize the entire Office suite for their needs. Check out Mastering VBA for Office 2010 today!

More ExcelTips (ribbon)

Replacing Characters at the End of a Cell

The Find and Replace capabilities of Excel can come in handy, but they can't accomplish all your replacement needs. One ...

Discover More

Replacing Only Whole Words in Excel

Excel's Find and Replace capabilities are handy, but they aren't as full-featured as those in Word. One shortcoming is ...

Discover More

Limitations On Finding Characters

When you search for information in a worksheet, you expect Excel to return results that make sense. If you don't get a ...

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 8 - 5?

There are currently no comments for this tip. (Be the first to leave your comment—just use the simple form above!)


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.