» Insert headers and footers using VBA in Microsoft Excel
VBA macro tip contributed by Erlandsen Data Consulting offering Microsoft Excel Application development, template customization, support and training solutions
CATEGORY - Printing in VBA
VERSION - All Microsoft Excel Versions
It also inserts the complete path to the workbook.
Sub InsertHeaderFooter()
' inserts the same header/footer in all worksheets
Dim ws As Worksheet
Application.ScreenUpdating = False
For Each ws In ActiveWorkbook.Worksheets
Application.StatusBar = "Changing header/footer in " & ws.Name
With ws.PageSetup
.LeftHeader = "Company name"
.CenterHeader = "Page &P of &N"
.RightHeader = "Printed &D &T"
.LeftFooter = "Path : " & ActiveWorkbook.Path
.CenterFooter = "Workbook name &F"
.RightFooter = "Sheet name &A"
End With
Next ws
Set ws = Nothing
Application.StatusBar = False
End Sub
Book Store:
Recommended Books:
- Investing for Dummies, Third Edition
- Financial Statement Analysis with S&P insert card
- Writing Excel Macros with VBA, 2nd Edition
- Financial Statements: A Step-By-Step Guide to Understanding and Creating Financial Reports
- Microsoft PowerPoint Version 2002 Step by Step
- MP Managerial Accounting w/ Topic Tackler, Net Tutor, & PowerWeb
No comments have been submitted.

