Using VBA to print correct info on page footers

AidanDanby

Board Regular
Joined
Jan 24, 2013
Messages
176
Office Version
  1. 365
Hi All & Happy New Year,

I have a spreadsheet with a singe worksheet in it named "Mainsheet". Depending on how much info is inputted on this determines how many pages are required to print. The maximum number of page is six. I have written a little VBA so that the correct number of pages are printed but I cannot fathom how to get the footer to be correct. For example if there are 4 pages in total I want it to state 1 of 4, 2 of 4 and so on, on the footer. If 5 pages - 1 of 5, 2 of 5 and so on.

I have looked through Google for help but just cannot find an answer.

Can anyone help please?

Cheers,

Aidan
 

Excel Facts

Back into an answer in Excel
Use Data, What-If Analysis, Goal Seek to find the correct input cell value to reach a desired result
Happy New Year to you too.

FYI, that is a built in function. VBA is not required.

Please try pasting the following in a "custom footer"

Code:
Page &[Page] of &[Pages]
 
Upvote 0

Forum statistics

Threads
1,213,526
Messages
6,114,136
Members
448,551
Latest member
Sienna de Souza

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