How to put cell value in header/footer in Excel?
We can easily insert header or footer containing file path, file name, current date or other information with Excel’s feature, but, sometimes, we want to use a cell value as the header or footer in Excel. How can we put the contents of a cell into header or footer in the workbook?
Put cell value in header or footer of a worksheet with VBA code
Put cell value in header or footer of all worksheets with VBA code
Insert file information into header/footer with Kutools for Excel
Put cell value in header or footer of a worksheet with VBA code
If you want to place a cell content in the header or footer of the current worksheet, the following VBA code can help you. Please do as following steps:
1. Active your worksheet which you want to insert herder or footer with a cell value, then hold down the ALT + F11 keys, and it opens the Microsoft Visual Basic for Applications window.
2.Click Insert > Module, and paste the following code in the Module Window.
VBA code: put a specified cell value in header of a worksheet
Sub HeaderFrom()
'Update 20140318
Dim WorkRng As Range
On Error Resume Next
xTitleId = "KutoolsforExcel"
Set WorkRng = Application.Selection.Range("A1")
Set WorkRng = Application.InputBox("Range (single cell)", xTitleId, WorkRng.Address, Type:=8)
Application.ActiveSheet.PageSetup.LeftHeader = WorkRng.Range("A1").Value
End Sub
3. Then press F5 key to run this code, a dialog will pop out to remind you selecting a cell that you want to put its content into the header.
4. And then click OK, this specified cell value has been inserted into the current worksheet left header. You can view the header by clicking File > Print. See screenshot:
Notes:
1. If you want to use the cell content as footer of the active worksheet, you can apply this code:
VBA code: put a specified cell value in footer of a worksheet
Sub FooterFrom()
'Update 20140318
Dim WorkRng As Range
On Error Resume Next
xTitleId = "KutoolsforExcel"
Set WorkRng = Application.Selection.Range("A1")
Set WorkRng = Application.InputBox("Range (single cell)", xTitleId, WorkRng.Address, Type:=8)
Application.ActiveSheet.PageSetup.LeftFooter = WorkRng.Range("A1").Value
End Sub
2. You can also apply the above codes for inserting cell value to right header/footer or center header/footer, just replace the LeftHeader / LeftFooter with RightHeader / RightFooter or CenterHeader / CenterFooter in the codes.
Put cell value in header or footer of all worksheets with VBA code
Sometimes, you want to insert header or footer with a selected cell's contents to all worksheets of your opening workbook, with the above code, you need to repeat them time and time again. In this case, the following VBA code can add the cell content to herder or footer of the whole workbook at once.
1. Active your workbook which you want to insert herder or footer with a cell value, then hold down the ALT + F11 keys, and it opens the Microsoft Visual Basic for Applications window.
2. Click Insert > Module, and paste the following code in the Module Window.
VBA code: put a specified cell value in footer of all worksheets
Sub AddFooterToAll()
'Update 20140318
Dim WorkRng As Range
On Error Resume Next
xTitleId = "KutoolsforExcel"
Set WorkRng = Application.Selection.Range("A1")
Set WorkRng = Application.InputBox("Range (single cell)", xTitleId, WorkRng.Address, Type:=8)
For Each ws In Application.ActiveWorkbook.Worksheets
ws.PageSetup.LeftFooter = WorkRng.Range("A1").Value
Next
End Sub
3. Then press F5 key to execute this code, a dialog will pop out to remind you selecting a cell that you want to put its content in the footer of the whole workbook.
4. And then click OK, this selected cell value has been added to all of the worksheets' left footer. You can view the footer by clicking File > Print. See screenshot:
Notes:
1. If you want to use the cell content as header of the whole workbook, you can apply this code:
VBA code: put a specified cell value in header of all worksheets
Sub AddHeaderToAll()
'Update 20140318
Dim WorkRng As Range
On Error Resume Next
xTitleId = "KutoolsforExcel"
Set WorkRng = Application.Selection.Range("A1")
Set WorkRng = Application.InputBox("Range (single cell)", xTitleId, WorkRng.Address, Type:=8)
For Each ws In Application.ActiveWorkbook.Worksheets
ws.PageSetup.LeftHeader = WorkRng.Range("A1").Value
Next
End Sub
2. Substitute RightHeader/Footer or CenterHeader/Footer for LeftHeader/Footer in the above codes if you want your header or footer differently positioned.
Insert file information into header/footer with Kutools for Excel
If you want to insert filer information to header or footer, such as worksheet/workbook name, workbook path and so on, you can use Kutools for Excel’s Insert Workbook Information utility if you have installed Kutools for Excel.
Kutools for Excel, with more than 300 handy functions, makes your jobs more easier. | ||
After free installing Kutools for Excel, please do as below:
1. Click Kutools Plus > Workbook > Insert Workbook Information. See screenshot:
2. In the Insert Workbook Information dialog, check the information you need to insert under Information section, and check Header or Footer as you like.
Tip: you can insert the information at three location of header or footer: center, left or right.
3. Click Ok. Then you can go to View > Page Layout to view the header.
With Insert Workbook Information, you also can insert file information to a cell or a range of cells. Click here to know more about this utility.
Insert workbook information at cell/header/footer

Related articles:
How to insert file name or path into cell / header or footer in Excel?
How to insert and delete header, footer, and header picture in Excel?
Best Office Productivity Tools
Supercharge Your Excel Skills with Kutools for Excel, and Experience Efficiency Like Never Before. Kutools for Excel Offers Over 300 Advanced Features to Boost Productivity and Save Time. Click Here to Get The Feature You Need The Most...
Office Tab Brings Tabbed interface to Office, and Make Your Work Much Easier
- Enable tabbed editing and reading in Word, Excel, PowerPoint, Publisher, Access, Visio and Project.
- Open and create multiple documents in new tabs of the same window, rather than in new windows.
- Increases your productivity by 50%, and reduces hundreds of mouse clicks for you every day!









