How to put cell value in header/footer in Excel?
In Microsoft Excel, it is simple to insert information such as the file path, file name, current date, or other built-in details into headers or footers using native Excel features. However, there are scenarios where you need to use the actual content of a specific cell as a header or footer. This capability is not provided directly by Excel’s standard interface, leading to the question: how can you insert a cell value into a header or footer in your worksheet? Many users encounter this requirement when preparing reports, forms, or data exports where dynamic information, such as a client name or a custom date, should be reflected in the print header or footer, so that each printout contains the most up-to-date context from the sheet itself. The solutions below address this need, showing both VBA and third-party approaches, and discuss when each method is most suitable.
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
Copying cell contents manually to the header or footer dialog
Put cell value in header or footer of a worksheet with VBA code
If you want to display the content of a specific cell in the header or footer of your current worksheet, this is not possible via Excel’s standard header/footer interface. However, you can achieve this using a simple VBA macro.
First, ensure you save your workbook before running any VBA code, as macros modify objects and cannot be undone. Also, make sure your Excel settings allow macros to run.
1. Activate the worksheet where you want to place a cell value in the header or footer. Press ALT + F11 to bring up the Microsoft Visual Basic for Applications window.
2. Click Insert > Module, and paste the following code into the new 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. Press F5 (or click the Run button) to execute this macro. A dialog box will appear prompting you to select the cell whose value you wish to use in the header.
4. After selecting the cell and clicking OK, the value of the chosen cell will be inserted into the left header of your active worksheet. To view the header, go to File > Print (or use Page Layout view). See example below:
Notes:
- If you want to display the cell's content in the footer instead of the header, use the following code. The operational steps are the same—simply paste this code into a module and run it.
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
- To change the position, replace LeftHeader or LeftFooter in the code with CenterHeader, RightHeader, CenterFooter, or RightFooter as needed. For example, to insert the value in the center header, change
LeftHeader
toCenterHeader
. - Always ensure the cell reference is valid before running the script. If you try referencing a blank cell, the header/footer will be blank.
- After running the macro, if you modify the source cell, the header/footer will not update automatically; you will need to re-run the macro to update the information displayed.
- This VBA method is recommended when you want to automate cell-to-header actions without needing frequent updates, or when working on templates with dynamic content per printout.
- If you encounter a “Macros are disabled” warning, ensure macro settings are enabled in File > Options > Trust Center.
Put cell value in header or footer of all worksheets with VBA code
When you need to apply the value of a specific cell as a header or footer across all sheets in your workbook, it would be time-consuming to run the previous code for each worksheet individually. In such cases, you can use another VBA macro designed to insert a chosen cell's content into the header or footer of every worksheet in your workbook in one operation. This is common when distributing reports that should bear consistent header/footer information throughout.
1. Open the workbook where you want to apply the change, and press ALT + F11 to launch the Visual Basic for Applications window.
2. In the VBA editor, click Insert > Module, then copy and paste the following macro into 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. Press F5 to run this macro. A dialog box will appear for you to select the target cell whose value should appear in each worksheet’s footer.
4. Once you select the cell and click OK, this cell value will be inserted into the left footer of every worksheet in the workbook. You can check the footer assignment by navigating to File > Print.
Notes:
- To use a cell value in the header across all worksheets, apply the following code instead. The process for entering and executing the code is identical:
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
- To insert the value in the right or center position of the header/footer, simply replace LeftHeader/LeftFooter with CenterHeader/CenterFooter or RightHeader/RightFooter in the script.
- Be aware that undo actions do not apply to changes made using VBA macros. Save your document beforehand to avoid losing data if the result is unexpected.
- This approach is best for workbooks where all sheets share common header/footer requirements. When sheets need different content, consider running the single-sheet macro separately on each.
- If you encounter issues where headers/footers do not update as expected, ensure you do not have Protected Sheets or Workbook Protection enabled.
Insert file information into header/footer with Kutools for Excel
In cases where you want to quickly and flexibly insert file-related information—such as the worksheet name, workbook name, or file path—into the header or footer, Kutools for Excel provides a dedicated utility called Insert Workbook Information. This tool is especially suitable if you prefer a code-free solution, require batch processing, or want to insert several built-in document properties without manual entry or risk of error. Kutools makes the process accessible for users who do not wish to interact with VBA or who regularly need to update headers/footers based on workbook metadata.
After free installing Kutools for Excel, follow these steps:
1. Go to the Kutools Plus tab, then select Workbook > Insert Workbook Information.
2. In the Insert Workbook Information dialog box, select the specific information you wish to insert (e.g., workbook path, file name, worksheet name, etc.) under the Information section. Then, specify whether you want to insert it into the header or footer by checking Header or Footer.
Tip: You can choose the position within the header or footer—center, left, or right—using the location options. This is helpful for structured layouts, such as placing the file path on the left and the sheet name in the center.
3. Click OK to apply your settings. To review the results, go to View > Page Layout or use File > Print Preview.
With the Insert Workbook Information feature, you can also insert this information directly into cells or a range of cells—enabling you to use such details for formulas, display, or further automation tasks. Click here to know more about this utility.
This method works particularly well for users who want easy access to document properties without interacting with macros or formulas. Compared to manual editing, Kutools ensures consistency and saves considerable time, especially for those regularly needing to update document references.
If the information in your header or footer does not seem to update automatically, check if the workbook is set to Manual Calculation, as some headers/footers require a document refresh to display the latest data.
Copying cell contents manually to the header or footer dialog
If you only need to update the header or footer with cell content occasionally and want to avoid VBA and add-ins, you can copy the cell value and paste it manually into the header/footer dialog. Double-click the header/footer section in Page Layout view and paste the cell value using Ctrl+V. The downside is this is manual—you need to update the value each time it changes.
When using manual or print-title approaches, remember that they are less dynamic for "true" header/footer placement, and require action each time the underlying information changes. On the other hand, VBA macros and tools like Kutools offer streamlined, repeatable workflows especially useful for large workbooks or automated report generation. If you encounter unexpected behavior or errors with VBA, always check your macro security settings and inspect for locked or protected worksheets. Before using third-party add-ins, verify they are from reputable sources and compatible with your Excel version. When working with sensitive or critical files, it is good practice to save a backup prior to running macros.
Demo: Insert workbook information to 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!
All Kutools add-ins. One installer
Kutools for Office suite bundles add-ins for Excel, Word, Outlook & PowerPoint plus Office Tab Pro, which is ideal for teams working across Office apps.





- All-in-one suite — Excel, Word, Outlook & PowerPoint add-ins + Office Tab Pro
- One installer, one license — set up in minutes (MSI-ready)
- Works better together — streamlined productivity across Office apps
- 30-day full-featured trial — no registration, no credit card
- Best value — save vs buying individual add-in