VBA & Macro Problems

Fix Excel Page Header Reappears After Deletion Using VBA

Camila MilosovichCamila Milosovich Oct 16, 2026 871 views

Question details

The user needs a permanent solution to remove a stubborn worksheet header that will not stay deleted using standard Page Setup tools.

How to Fix an Excel Page Header that Reappears After Deletion
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 you start

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.

Solution 1Recommended

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.

1
Open the VBA Editor

Press Alt + F11 on your keyboard to open the Visual Basic for Applications (VBA) editor.

2
Insert a New Module

In the top menu, click Insert and select Module to create a blank workspace for your code.

3
Paste the Cleanup 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

4
Run the Macro

Ensure the problematic worksheet is active in Excel, return to the VBA editor, and press F5 to execute the code.

5
Save and Verify

Close the VBA editor, save the workbook, and reopen it. Check the Print Preview to ensure the headers are permanently removed.

Targeting Other Sheets: If you need to clear headers on a different worksheet, simply activate that sheet first before running the macro, or modify the code to target a specific sheet name like Sheets("Report Table").Activate.

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. 1. Open your Document: Launch WPS Spreadsheet and open your existing Excel workbook.
  2. 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. 3. Select Header/Footer: Switch to the Header/Footer tab within the Page Setup window.
  4. 4. Clear the Header: Click the Header drop-down menu, select '(none)', and click OK to apply the changes permanently.
Reliably clear stubborn headers and footers with a single click in the Page Setup menu.Fully compatible with Microsoft Excel formats (.xlsx, .xls, and .xlsm).Includes a built-in Document Inspector to easily sanitize files before sharing.Free, lightweight, and fast alternative for all your daily spreadsheet tasks.
microsoft office alternative - wps office

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.