Please Note: This article is written for users of the following Microsoft Excel versions: 97, 2000, 2002, and 2003. If you are using a later version (Excel 2007 or later), this tip may not work for you. For a version of this tip written specifically for later versions of Excel, click here: Find and Replace in Headers.
by Allen Wyatt
(last updated April 29, 2016)
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 o 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:
This add in searches regularly, but also searched in lots of other areas including headers and footers.
ExcelTips is your source for cost-effective Microsoft Excel training. This tip (3928) applies to Microsoft Excel 97, 2000, 2002, and 2003. You can find a version of this tip for the ribbon interface of Excel (Excel 2007 and later) here: Find and Replace in Headers.
Create Custom Apps with VBA! Discover how to extend the capabilities of Office 2013 (Word, Excel, PowerPoint, Outlook, and Access) with VBA programming, using it for writing macros, automating Office applications, and creating custom applications. Check out Mastering VBA for Office 2013 today!
The Find and Replace capabilities of Excel can come in handy, but they can't accomplish all your replacement needs. One such ...Discover More
Want to make instances of a given word or phrase bold throughout a worksheet? Here's a way you can make the change quickly.Discover More
Need to add some characters to the beginning of the contents in a range of cells? It's not as easy as you might hope, but ...Discover More
FREE SERVICE: Get tips like this every week in ExcelTips, a free productivity newsletter. Enter your address and click "Subscribe."
Got a version of Excel that uses the menu interface (Excel 97, Excel 2000, Excel 2002, or Excel 2003)? This site is for you! If you use a later version of Excel, visit our ExcelTips site focusing on the ribbon interface.