Page number in cell

  • Thread starter Thread starter davidaloi
  • Start date Start date
VBA macro.

Sub PrintWithPgNumInTitleRow()
'print with page number in A1
Dim NumPages As Long, Pg As Long
NumPages = ExecuteExcel4Macro("Get.document(50)")
ActiveSheet.Range("TotalPages").Value = NumPages
For Pg = 1 To NumPages
With ActiveSheet
.Range("A1").Value = Pg
.PrintOut from:=Pg, To:=Pg
End With
Next Pg
End Sub

Gord Dibben Excel MVP
 

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

Back
Top