This article explains page numbering in Excel 2019, 2016, 2013 and lower. Find out how to insert page numbers in Excel if your workbook contains one or multiple worksheets, how to set a custom number for the starting sheet or delete number watermarks added incorrectly. Continue reading
Comments page 2. Total comments: 62
Public Function PageNumber( _
Optional ByRef target As Excel.Range, _
Optional ByVal nStart As Long = 1&) As Variant
Dim pbHorizontal As HPageBreak
Dim pbVertical As VPageBreak
Dim nHorizontalPageBreaks As Long
Dim nPageNumber As Long
Dim nVerticalPageBreaks As Long
Dim nRow As Long
Dim nCol As Long
On Error GoTo ErrHandler
Application.Volatile
If target Is Nothing Then _
Set target = Application.Caller
With target
nRow = .Row
nCol = .Column
With .Parent
If .PageSetup.Order = xlDownThenOver Then
nHorizontalPageBreaks = .HPageBreaks.Count + 1&
nVerticalPageBreaks = 1&
Else
nHorizontalPageBreaks = 1&
nVerticalPageBreaks = .VPageBreaks.Count + 1&
End If
nPageNumber = nStart
For Each pbHorizontal In .HPageBreaks
If pbHorizontal.Location.Row > nRow Then Exit For
nPageNumber = nPageNumber + nVerticalPageBreaks
Next pbHorizontal
For Each pbVertical In .VPageBreaks
If pbVertical.Location.Column > nCol Then Exit For
nPageNumber = nPageNumber + nHorizontalPageBreaks
Next pbVertical
End With
End With
PageNumber = nPageNumber
ResumeHere:
Exit Function
ErrHandler:
'Could use much more error handling...!
PageNumber = CVErr(xlErrRef)
Resume ResumeHere
End Function
now come to cell & put this formula =pagenumber()
What is this
hello miss
how to make more page in worksheet in excel? plz tell me.
Too much helpful. Thanks
I WANT THE PAGE NUMBER NOT START FROM NO. 1.. BUT OTHER THAN NO.1.. EXAMPLE START FROM NO. 4.. CAN U PLEASE HELP ME ON THIS? :(
Hi AWAN,
Please look at the "Customize page numbering for the starting page" section, it should help:
https://www.ablebits.com/office-addins-blog/excel-insert-page-numbers/#customize-page-numbers
i want the page number in particular cell
thank you for teaching me page numbering. It will help me a lot.
Before installing Windows 10, I had an excel sheet where the page numbers showed up kinda like a watermark on the pages. These numbers showed onscreen (very large) but did not show up in print.
Now, they are not there, and I have no idea how to get them back.
I have question regarding assign page no. in same sequence in different worksheets i.e if the last page of 1st worksheet is 10 then the second worksheet must be start from the 11 automatically without assign the first starting page no. Waiting for you guidelines in this regard.
Kamal Bhardwaj
9560386726.
Hi, does anyone has solution to the query posted by @Kamal
I have a same question like that. Yes, of course , I want to know it.
Any Body can solve this question?
This was fantastic thank you very much!
My excel 2013 work book contains 3 worksheets Sheet 1 contains 10 pages, Sheet 2 contains 15 pages and Sheet 3 contains 25 pages. I want to print two types of numbering in footer. Left footer is Page x of y for worksheet and right footer is Page x of y of workbook while print using Entire workbook option. Eg: Footer of Sheet 1 is "Sheet Page 1 of 10" in left footer and "Workbook Page 1 of 50" in right footer. How can it possible
I am printing a cover page, I don't want it number so I set "first page number" = 0. This worked great second printed page started at 1 BUT the "of pages" didn't start at zero, it counted the cover page, so it is showing one more page then is actually printed. any way to reset this counter? I tried putting &([pages]-1) but it didn't like that. Any suggestions.
How can I insert page number in multiple sheets starting from certen number. If I check all sheets and than in footer insert number its ok, every page has different number. But if i in First page number erase "Auto" and insert some number, all pages have same number. How can I numerate multiple pages starting from certen number?
Thanks
Make sure that you do it in two steps. First highlight all the tabs to insert the automatic page numbers into each tab. Then, only select the first tab and change the starting page number. If all tabs are highlighted when you do step 2 it will start every tab at the same number.
Hello, Branko,
You can try the following workaround:
1. Print out certain number of pages without numbers.
2. Print out the second part of pages with numbers (the first page number can be negative).
timely. thanks a lotest.
Glad that you found the article helpful, Cephas.
this really gave me a tough time,imagine i was even trying to convent the document into word for this purpose
That's good that you found a solution, Cephas! We are always happy to help.
Hi.. I found this tips very nice and helpful for printing in excel. Thanks Keep it up.
Thank you for the feedback, Dillip!
thank you it was so helpfully!
Glad that you found the article helpful, Gelare.
when attempting to print multiple sheets (with multiple pages printing from each sheet) i can get the correct numbers to print sequentially (and they show up correctly in print preview as well) but they do not show correctly in regular page layout view. what happens in page layout view is that one sheet will show 1 of 2, 2 of 2, and then the next sheet will show the same. In page layout view you can't go from one tab to the next (even if they are grouped) and see 1 of 47, 2 of 47, etc. can this be accomplished? thanks!
Can somebody answer this? I have the exact same problem. Would be very glad to get an answer
Was there no response to this question?
I have Excel 2013. In earlier versions, I could enter which page number I wanted to start with in the footer or header. Now it's an Auto-function, and I can't find out where to change that.
I want the 2 first pages without page numbers, and then the 3rd page to start as Page 1. Any ideas how I obtain that?
Thanks in advance
Tina Depner
Hello, Tina,
Looks like your task needs a macro or hard coding. Sorry, we cannot help you with this.
3 years later i was having the same problem but have just sorted it! On the page you want Page 1, type 1 into First Page in Page Setup. On the continuous tabs type "auto" into First Page Number. Sorted! :)
Thanks Claire! This gave the exact tip I needed.
I needed to start my first worksheet at a specific page number (to append to another report), but then needed my 2nd, 3rd, 4th, etc worksheet to automatically follow on in the page numbering. Your combination of setting the starting page number and then using "auto" in the same page number section for all other worksheets was exactly what I needed. Thank you.
Author, can this be added to the main section above? This is extremely useful.
Thanks for the article. It really helped and presented things in a quick and no-nonsense manner.
Thank you for the feedback, Jean,
Happy to know that you liked the article!
Hello.This post was extremely fascinating, especially since I was looking for thoughts on this matter last week.
Alex Ber http://www.academia.edu/
Hi Alex,
Thank you for the feedback. Glad to hear you found the article helpful.
dear Maria
How can can I insert page numberrring i a specific cell I want, not in the header or footer line???
Thanks beforehand!!!
Ani
Dear Ani,
Looks like there's no easy solution for this and it would require VBA. Sorry, we cannot help you with this.