VBA & Macro Problems

Remove Excel Header and Footer Text While Keeping a Watermark

Olivia MillerOlivia Miller Nov 18, 2026 869 views

Question details

Remove worksheet header and footer text with VBA while preserving a watermark stored as a header picture.

Remove Excel Header and Footer Text While Keeping a Watermark
Product
Microsoft Excel
Device & OS
not provided
Scenario
A worksheet has header and footer text and a watermark inserted as a header picture.
Observed behavior
Clearing the header string also removes the graphic placeholder needed to display the watermark.
Before you start

In desktop Excel, open Page Layout view and check which header section contains the watermark picture. The example below assumes the picture is already assigned to the center header and that no other header or footer pictures need to be preserved.

Solution 1Recommended

Keep the Center Header Picture Placeholder When Clearing Text

Use this VBA macro when the watermark is already stored as a center-header picture.

The &G code is the placeholder that displays a header picture. Set the center header directly to &G instead of clearing it first; this removes its text while retaining the picture placeholder.

1
Open the VBA editor

In desktop Excel, select the worksheet to update, then choose Developer > Visual Basic.

2
Insert the macro

In the VBA editor, choose Insert > Module and paste: Sub KeepWatermark() With ActiveSheet.PageSetup .LeftHeader = "" .CenterHeader = "&G" .RightHeader = "" .LeftFooter = "" .CenterFooter = "" .RightFooter = "" End With End Sub

3
Run and check the result

Return to Excel, choose Developer > Macros, select KeepWatermark, and click Run. Open File > Print to check that the watermark remains and the unwanted text is gone.

Keep the Center Header Picture Placeholder When Clearing Text
Check the picture location: If the watermark is in the left or right header, use &G in that section instead. Clearing another header or footer section also removes any picture placeholder stored there.
Free Microsoft Office alternative

Edit Excel Workbooks with WPS Spreadsheets

WPS Office is a free, lightweight alternative for working with Excel files in a familiar interface. Open existing workbooks to migrate your everyday spreadsheet work, and check header pictures and macros for compatibility before relying on them.

Open and edit Microsoft Excel XLSX filesReview spreadsheet headers and print layoutsUse a familiar spreadsheet interface for an easier transitionWork with a lightweight office suite for free
microsoft office alternative - wps office

Frequently Asked Questions

Why does clearing the header remove my watermark?

A header watermark is displayed through the &G picture placeholder. Setting that header to an empty string removes the placeholder along with the text.

How do I preserve a watermark in the left header instead?

In the macro, set .LeftHeader = "&G" and clear the other sections only if they contain no pictures you need to keep. The picture must already be assigned to the left header.

Can I run this VBA macro in Excel for the web?

No. Open the workbook in desktop Excel and use Developer > Visual Basic to add the macro, then Developer > Macros to run it.

How can I check whether the watermark will print?

After running the macro, select File > Print and inspect the print preview. If the watermark is missing, check that the picture is assigned to the header section containing &G.