Fix Excel Page Header Reappears After Deletion Using VBA
Question details
The user needs a permanent solution to remove a stubborn worksheet header that will not stay deleted using standard Page Setup tools.

- Product
- Excel
- Device & OS
- not provided
- Scenario
- Attempting to clear a header for printing or final document preparation, but standard removal methods (like the Header & Footer tools or Document Inspector) fail to permanently delete it.
- Observed behavior
- The deleted header continuously reappears in the print preview and Header/Footer dialog box after the workbook is saved and reopened.
Before running any VBA macros, ensure you have saved a backup copy of your workbook, as macro actions cannot be undone using the standard Excel Undo feature.
Use a VBA Macro to Force Clear All Headers and Footers
Running a short VBA script bypasses the graphical interface and forces the underlying workbook properties to blank, resolving persistent glitches.
Sometimes standard Excel interface commands fail to overwrite corrupted Page Setup properties. A VBA macro directly targets the active sheet's configuration and permanently resets the header and footer values.
Press Alt + F11 on your keyboard to open the Visual Basic for Applications (VBA) editor.
In the top menu, click Insert and select Module to create a blank workspace for your code.
Copy and paste the following code into the module window: Sub DeleteHeaderFooter() ActiveSheet.PageSetup.LeftHeader = "" ActiveSheet.PageSetup.CenterHeader = "" ActiveSheet.PageSetup.RightHeader = "" ActiveSheet.PageSetup.LeftFooter = "" ActiveSheet.PageSetup.CenterFooter = "" ActiveSheet.PageSetup.RightFooter = "" End Sub
Ensure the problematic worksheet is active in Excel, return to the VBA editor, and press F5 to execute the code.
Close the VBA editor, save the workbook, and reopen it. Check the Print Preview to ensure the headers are permanently removed.
Remove Hidden Headers Using the Document Inspector
If headers exist on hidden worksheets or as residual metadata, using the built-in Document Inspector can help identify and remove them globally.
Easily Manage Headers and Footers with WPS Spreadsheet
WPS Spreadsheet offers a highly intuitive Page Layout interface that reliably manages headers, footers, and print settings without requiring complex VBA code workarounds.
- 1. Open your Document: Launch WPS Spreadsheet and open your existing Excel workbook.
- 2. Navigate to Page Setup: Click on the Page Layout tab on the top ribbon, then click the small Page Setup dialog box launcher icon.
- 3. Select Header/Footer: Switch to the Header/Footer tab within the Page Setup window.
- 4. Clear the Header: Click the Header drop-down menu, select '(none)', and click OK to apply the changes permanently.

Frequently Asked Questions
Why do deleted Excel headers keep reappearing after saving?
This glitch typically happens due to minor file corruption, conflicting custom views, or locked Page Setup properties that fail to update correctly through the graphical user interface. A VBA macro bypasses the GUI to directly overwrite these locked settings.
How do I run this macro on all worksheets simultaneously?
You can modify the VBA macro to loop through all sheets. Use the code: Dim ws As Worksheet For Each ws In ActiveWorkbook.Worksheets ws.PageSetup.LeftHeader = "" ' (add the other header/footer positions here) Next ws
Can I remove headers by saving the file in a different format?
Yes, occasionally saving your problematic .xlsx file as an Excel Binary Workbook (.xlsb) or a standard Excel 97-2003 Workbook (.xls), and then saving it back to .xlsx can strip out corrupted XML print settings that cause headers to reappear.




