HeaderFooter Object (Excel)

Office 2013 and later
GitHub-Mark-64px

Contribute to this content

Use GitHub to suggest and submit changes. See our guidelines for contributing to VBA documentation.

Represents a single header or footer. The HeaderFooter object is a member of the HeadersFooters collection.

You can also return a single HeaderFooter object by using the HeaderFooter property with a Selection object.

Note Note

You cannot add HeaderFooter objects to the HeadersFooters collection.

Use the DifferentFirstPageHeaderFooter property with the PageSetup object to specify a different first page.

The following example adds the date and time to the center header in the active worksheet.

With ActiveSheet.PageSetup 
 .CenterHeader = "&D&T" 
 .OddAndEvenPagesHeaderFooter = False 
 .DifferentFirstPageHeaderFooter = False 
 .ScaleWithDocHeaderFooter = True 
 .AlignMarginsHeaderFooter = True 
End With
Show: