Pageheader and footer

New Contributor

I am creating a multisheet workbook where I want to insert the contens of a cell into the pagefoot, is that possible and in that case how.

2 Replies



Although you can add different types of information to the Header or Footer (File Name, Sheet Name, Date, ...etc), however, using the Page Setup dialog box, you cannot grab a value from a cell in the worksheet by typing =cellReference


The Good News is, You can create a very simple code in VBA to do that for you.

The code should be attached to the Before Print Event of the Workbook:

  • Go To the Visual Basic Editor >>ALT + F11
  • To the Left side (Project Explorer) >> Right Click ThisWorkbook >> 
  • Select View Code
  • In the VBE>> click on the drop list to the left and select WorkBook
  • Then click on the drop list to the right and select Before Print
  • Assuming you want to link to the value in Cell C5 in each sheet,

Here is the code:


Private Sub Workbook_BeforePrint(Cancel As Boolean)

    Dim Sh As Worksheet

    For Each Sh In Me.Worksheets

    Sh.PageSetup.CenterFooter = Sh.Range("C5").Value & VBTab & Date

    Next Sh

End Sub


NB: To have in the Header use CenterHeader instead

VBTab will add a Space and I am joining to the Date



Hope that Helps

Nabil Mourad

Thank you Nabil
This was just what I wanted

Related Conversations
Extentions Synchronization
Deleted in Discussions on
3 Replies
Tabs and Dark Mode
cjc2112 in Discussions on
35 Replies
Stable version of Edge insider browser
HotCakeX in Discussions on
35 Replies
Security Community Webinars
Valon_Kolica in Security, Privacy & Compliance on
9 Replies
flashing a white screen while open new tab
Deleted in Discussions on
14 Replies