Insert a header in all sheets
This tutorial shows how to insert a header in all sheets using Excel and VBA
Select all Sheets >Insert tab > Text group > Header & Footer > Enter header > Click anywhere on a sheet
1. Select all of the Sheets in the workbook. Note: In this example we have selected all three sheets in a workbook. |
2. Select the Insert tab. |
3. Select the Text group. 4. Click on Header & Footer. |
5. Enter a header in any of the header areas. 6. Click anywhere on a sheet. Note: In this example we have entered a header of "Exceldome" in the center header area. By default the centre box is selected. |
Sub Insert_header()
'declare a variable
Dim ws As Worksheet
For Each ws In ThisWorkbook.Sheets
With ws.PageSetup
.LeftHeader = ""
.CenterHeader = "Exceldome"
.RightHeader = ""
.CenterHeader = "Exceldome"
.RightHeader = ""
End With
Next ws
Set ws = Nothing
End Sub
NOTES
Note 1: This VBA code will insert a header of "Exceldome" in the center header area of all of the worksheets in a workbook where the VBA code is written.
Note 1: This VBA code will insert a header of "Exceldome" in the center header area of all of the worksheets in a workbook where the VBA code is written.
RELATED TOPICS
Related Topic | Description | Related Topic and Description |
---|---|---|
Insert a header | How to insert a header in a specific sheet | |
Insert a footer | How to insert a footer in a specific sheet |