page numbering when printing

vejv

New Member
Joined
Dec 10, 2020
Messages
2
Office Version
  1. 2019
Platform
  1. Windows
Hi,
I searched but couldn't find a solution to my problem.
I would need to print one page on sheet 1, but to have the number 00001 in cell AJ1, which increases with each copy. So each page will have its own number.
How to do it, thank you
(excuse english, i use google translator)
 

Excel Facts

Do you hate GETPIVOTDATA?
Prevent GETPIVOTDATA. Select inside a PivotTable. In the Analyze tab of the ribbon, open the dropown next to Options and turn it off
Welcome to MrExcel Message Board.
Please Test This:
VBA Code:
Sub PrintwithFooter()

Dim ws As Worksheet
Dim y As Long
Dim z As String

Application.ScreenUpdating = False

Set ws = Worksheets("Sheet1")
y = ws.Range("AJ1").Value
z = Application.WorksheetFunction.Text(y, "00000")
Debug.Print y
Application.ActiveSheet.PageSetup.CenterFooter = z
ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, Filename:=z _
    , Quality:=xlQualityStandard, IncludeDocProperties:=True, IgnorePrintAreas _
    :=False, OpenAfterPublish:=True
ws.Range("AJ1").Value = y + 1
Debug.Print ws.Range("AJ1").Value
Application.ScreenUpdating = True
End Sub
 
Upvote 0
I tried and it reports an error on this line
Set ws = Worksheets ("Sheet1")
 
Upvote 0

Forum statistics

Threads
1,215,066
Messages
6,122,948
Members
449,095
Latest member
nmaske

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top