Please Note: This article is written for users of the following Microsoft Excel versions: 2007, 2010, and 2013. 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: Putting Cell Contents in Footers.

Putting Cell Contents in Footers

by Allen Wyatt
(last updated April 16, 2018)

7

You may find it helpful to sometime place the contents of a cell into the footer of a worksheet, and to have the footer updated every time the contents of the cell changed. The easiest way to do this is with a macro. The following is an example of a macro that will place the contents of cell A1 into the left side of the footer:

Private Sub Worksheet_SelectionChange(ByVal Target As Excel.Range)
    ActiveSheet.PageSetup.LeftFooter = Range("A1").Text
End Sub

The macro is run every time Excel does its normal recalculation—meaning every time the contents of any cell changes or someone presses F9. If you want the contents to be in a different part of the footer, you can change LeftFooter to CenterFooter, or RightFooter.

To apply any formatting to the footer other than the default you will need to add special formatting codes, and you can also use special data codes that Excel recognizes for headers and footers. Both the special formatting and special data codes are quite lengthy and have been covered in other issues of ExcelTips.

If you are working with a very large worksheet, then changing the footer every time Excel recalculates may unnecessarily slow down your computer. After all, the footer remains invisible to the user until such time as the worksheet is actually printed. In this case, you simply need to rename the above macro to some other name that you would then manually execute as the last step before printing a worksheet.

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 (8965) applies to Microsoft Excel 2007, 2010, and 2013. You can find a version of this tip for the older menu interface of Excel here: Putting Cell Contents in 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

Paragraph Formatting Shortcuts

Paragraphs are one of the elemental building blocks in a Word document. Formatting those paragraphs is easy to do if you ...

Discover More

Changing Orientation of a Text Box

Want to change how a text box is oriented on the page? You can't do it, but you can adjust the dimensions of the box ...

Discover More

Positioning the Footnote Separator

The Footnote Separator, as its name implies, separates the footnotes on each page from the text on that page. If the ...

Discover More

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!

More ExcelTips (ribbon)

Putting Headers and Footers on Multiple Worksheets

You can easily create headers and footers for multiple worksheets by working with a selection set of the worksheets you ...

Discover More

Putting a Different Date in a Header

Today's date is easy to add to a header, but what if you want to add a date that is adjusted in some manner? Adding ...

Discover More

First and Last Names in a Page Header

When you have a worksheet that includes a long list of names, you may want the first and last names on each page to ...

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}] 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 five more than 8?

2018-04-16 14:06:53

Ken Kast

Recognizing the comment about not needing the footer updated till you are going to print, why not put the logic in a handler for the WorkboobBeforePrint event? That way there is no performance hit on the workbook being updated.


2016-07-27 08:36:58

Willy Vanhaelen

@Nick Cory

The macro presented in this tip is an excelent example of how you should NOT do it. This macro runs whenever the cell pointer is moved in the worksheet. This is rediculous.

The goal is that the footer reflects the contents of cell B7 and only when this cell changes the macro should run. This can be done in this way:

Private Sub Worksheet_Change(ByVal Target As Excel.Range)
If Target.Address = "$B$7" Then PageSetup.LeftFooter = Range("B7").Text
End Sub

IMPORTANT: this macro must be entered in de code page of the sheet who's footer you want to change. Simply right click the sheet's tab and select "View code". That's the place to be. Copy the 3 line macro above there. Do not change it's name. This macro cannot be seen in the list of macros, it runs autmatically.


2016-07-26 05:58:48

Nick Cory

Hi
I cannot get this to work. If I "create new macro" with the name "AutoFooter" it places this text automatcially at the start:

Sub AutoFooter()

End Sub

Regardless of where I then place the text:
Private Sub Workbook_SheetSelectionChange(ByVal Sh As Object, ByVal Target As Range)
ActiveSheet.PageSetup.CenterFooter = Range("B7").Text
End Sub

it is not seen to create the footer.

If I deleted the text
Sub AutoFooter()

End Sub

the macro disappears altogether from the list of macros.
My spreadsheet has only one worksheet but that has 80 pages.


2016-06-08 09:02:36

Janine Tremblay

I am using Office 2013 and need to do exactly what's described above, I understand (generally) how simple macros work but can't get this to work (running and testing on 2007). Specifically, I want my right footer set to reference a specific cell in the sheet it's running from, is this possible?
Thank you


2015-03-28 08:38:14

Steve P

Tried my best, but didn't really follow it.

Is it possible to have it in layman's terms.

Thanks
Steve


2013-12-10 16:28:40

Roger Shaw

Oops... the Tip as written, refers to a 'Worksheet_SelectionChange' event and does work (as written) if you put the code in the individual Worksheet Object - 'SheetN (Name)'. It runs only on that worksheet.

What I submitted was an Event Procedure (in the 'ThisWorksheet' object). This runs for every worksheet change.

If you use both, the Worksheet procedure runs first, then the Workbook procedure runs last.


2013-12-10 15:38:19

Roger Shaw

Using Excel 2010: this does not work as written - the function call has changed to this MS added an argument):

Private Sub Workbook_SheetSelectionChange(ByVal Sh As Object, ByVal Target As Range)

Make this change, and it works!


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.