We’ll use the following dataset to add page numbers and have them start with a different number.
Example 1 – Inserting the Page Number in the Header
Steps:
- Go to the Insert tab and select Header & Footer.
- Select the Header & Footer tab and choose Page Number.
- Among the three sections of the header section, we chose the right section as shown below.
- The page number will be inserted in the right section of the header section.
- Click on another cell and you will have the page number in the Excel header starting with 1.
- Go to the Page Layout tab and click on the Page Setup icon.
- The Page Setup dialog box appears.
- Type in the First page number.
- Click on OK.
- The page number starts at the value set in the box.
Read More: How to Insert Page Number Using VBA in Excel
Method 2 – Inserting the Page Number in the Footer
Steps:
- Go to the View tab and select Page Layout from the Workbook Views.
- The dataset will look like this.
- Select the place on the footer where you want to insert your page number. The Header & Footer tab will appear on the ribbon.
- Select Page Number from the Header & Footer Elements group in it.
- The footer will now look like this.
- Click on another cell and you will have the page number in the Excel footer.
- Go to the Page Layout tab and click on the Page Setup icon.
- When the Page Setup dialog box appears, type the desired starting number in First page number.
- Click on OK.
- Here’s the result.
Read More: How to Insert Sequential Page Numbers Across Worksheets
Method 3 – Inserting the Page Number in an Excel Cell via VBA
To use this feature, you need to show the Developer tab on your ribbon.
Steps:
- To open the VBA window, go to the Developer tab and select Visual Basic from the Code group.
- Go to the Insert tab on the VBA editor.
- Click on Module from the drop-down.
- A new module will be created.
- Select the module if it isn’t already selected.
- Insert the following code in it.
Sub Page_Count()
Dim xVCount As Integer
Dim xHCount As Integer
Dim xVBreak As VPageBreak
Dim xHBreak As HPageBreak
Dim xNumPage As Integer
xHCount = 1
xVCount = 1
If ActiveSheet.PageSetup.Order = xlDownThenOver Then
xHCount = ActiveSheet.HPageBreaks.Count + 1
Else
xVCount = ActiveSheet.VPageBreaks.Count + 1
End If
xNumPage = 2
For Each xVBreak In ActiveSheet.VPageBreaks
If xVBreak.Location.Column > ActiveCell.Column Then Exit For
xNumPage = xNumPage + xHCount
Next
For Each xHBreak In ActiveSheet.HPageBreaks
If xHBreak.Location.Row > ActiveCell.Row Then Exit For
xNumPage = xNumPage + xVCount
Next
ActiveCell = "Page " & xNumPage
End Sub
- You can close the VBA window.
- Turn on the page layout view.
- The sheet will look like this.
- Select the cell where you want to put the page number in. We have selected cell G35 for this.
- Go to the Developer tab and select Macros from the Code group.
- Select the Macro name you have just entered. Our macro name was Page_Count.
- Click on Run.
- You will see that the page number starts at 2 even though it is the first page of the dataset.
Read More: How to Insert Page Number in Excel Cell Not in Header
Download the Practice Workbook
Related Articles
- How to Use Formula for Page Number in Excel
- How to Insert Page Number in Excel
- How to Print Page Number in Excel
- How to Remove Page Number from Page Break Preview in Excel
<< Go Back to Page Number | Page Setup | Print in Excel | Learn Excel
Get FREE Advanced Excel Exercises with Solutions!