template + page numbers

S

someday

I have a template with a cell reserved for the page number. I need to print
the template 200 times with the page number incrementing for each page
printed.

In other words, the first page printed to read 1, second page 2, the third
3, etc.

How can I get this cell to increment 1 for each page printed.

Thank you in advance.
 
N

Nick Hodge

You could use the workbook_beforeprint() event to increment the cell

Private Sub Workbook_BeforePrint(Cancel As Boolean)
Worksheets("Sheet1").Range("A1").Value = _
Worksheets("Sheet1").Range("A1").Value + 1
End Sub

See here for implementation

http://www.nickhodge.co.uk/vba/vbaimplement.htm#EventCode

--
HTH
Nick Hodge
Microsoft MVP - Excel
Southampton, England
(e-mail address removed)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top