Insert sheet name into header
This tutorial shows how to insert the sheet name into a header in a specific sheet using Excel and VBA
Select sheet > Insert tab > Text group > Header & Footer > Select header area > Design tab > Header & Footer Elements group > Sheet Name > Click anywhere on the sheet
1. Select the sheet in which you want to insert the sheet name in the header. Note: In this example we have selected Sheet1, which will display this name in the header. |
2. Select the Insert tab. |
3. Select the Text group. 4. Click on Header & Footer. |
5. Select the header area in which you want to show the sheet name. Note: In this example we have selected the center header area. |
6. Select the Design tab. 7. Click on Sheet Name in the Header & Footer Elements group. |
8. This will insert &[Tab] in the selected header area which will return the sheet name. 9. Click anywhere on the sheet. |
Sub Insert_sheet_name_header()
'declare a variable
Dim ws As Worksheet
Set ws = Worksheets("Sheet1")
With ws.PageSetup
.CenterHeader = "&A"
End With
End Sub
NOTES
Note 1: This VBA code will insert the sheet name into the center header area of "Sheet1".
Note 1: This VBA code will insert the sheet name into the center header area of "Sheet1".
RELATED TOPICS
Related Topic | Description | Related Topic and Description |
---|---|---|
Insert a header | How to insert a header | |
Insert a footer | How to insert a footer in a specific sheet | |
Insert current date into header | How to insert the current date into a header in a specific sheet | |
Insert page numbers into header | How to insert page numbers into a header in a specific sheet |