Insert page number in a cell not in the header nor footer

YasserKhalil
PlatinumLounger
Posts: 4911
Joined: 31 Aug 2016, 09:02

Insert page number in a cell not in the header nor footer

Post by YasserKhalil »

Hello everyone
How can I insert page number into specific cell (the cell will be in fixed row that will be printed in each page)

Code: Select all

ws.PageSetup.PrintTitleRows = "$1:$3"
The cell is L1. Is that possibe?

the data in the same worksheet but about 20 pages.

User avatar
HansV
Administrator
Posts: 78237
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: Insert page number in a cell not in the header nor footer

Post by HansV »

When the worksheet is printed, rows 1 to 3 will be repeated "as is" at the top of each page. So L1 will show the same value on each printed page, not a dynamic page number.
An alternative would be to print each page separately after setting L1 to the number of the page to be printed. But if your worksheet has 25 pages, you'd end up with 25 print jobs...
Best wishes,
Hans

YasserKhalil
PlatinumLounger
Posts: 4911
Joined: 31 Aug 2016, 09:02

Re: Insert page number in a cell not in the header nor footer

Post by YasserKhalil »

Thanks a lot, my tutor. It seems using header is the best solution for that sitaution.

User avatar
HansV
Administrator
Posts: 78237
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: Insert page number in a cell not in the header nor footer

Post by HansV »

It is, indeed.
Best wishes,
Hans