Insert a header
This tutorial shows how to insert a header in a specific sheet using Excel and VBA
Insert tab > Text group > Header & Footer > Enter header > Click anywhere on the sheet
1. Select the Insert tab. |
2. Select the Text group. 3. Click on Header & Footer. |
4. Enter a header in any of the header areas. 5. Click anywhere on the 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
Set ws = Worksheets("Sheet1")
With ws.PageSetup
.LeftHeader = ""
.CenterHeader = "Exceldome"
.RightHeader = ""
.CenterHeader = "Exceldome"
.RightHeader = ""
End With
End Sub
NOTES
Note 1: This VBA code will insert a header of "Exceldome" in the center header area of only one worksheet, named "Sheet1".
Note 1: This VBA code will insert a header of "Exceldome" in the center header area of only one worksheet, named "Sheet1".
RELATED TOPICS
Related Topic | Description | Related Topic and Description |
---|---|---|
Show gridlines in a worksheet | How to show gridlines in a worksheet | |
Insert a footer | How to insert a footer in a specific sheet |