VBA for Roman Numeral Page Numbers

XcelNinja

New Member
Joined
May 12, 2014
Messages
2
I have a workbook with several tabs where the page numbers all need to be in the lower right footer in lower case Roman Numerals. The code I used is below. The page numbers are only on the 1st page of the document. I need them to number consecutively across all tabs. Right now I am only getting a page number of i on the very 1st page. I also need the page numbering to start with page 33 (in Roman Numerals of course). Any help is appreciated, I'm new to Macros.


Sub RomanPageNums()
Dim iPages As Integer
Dim J As Integer
' Get count of pages in active sheet
iPages = ExecuteExcel4Macro("Get.Document(50)")
' Loop through all the pages
' Print worksheet, page by page
With ActiveSheet
For J = 1 To iPages
' Set page letter
.PageSetup.RightFooter = LCase(Application.Roman(J))
' Print page J
.PrintOut From:=J, To:=J
Next J
End With
End Sub
 

Excel Facts

What did Pito Salas invent?
Pito Salas, working for Lotus, popularized what would become to be pivot tables. It was released as Lotus Improv in 1989.
Hi

You haven't said what version of Excel you are using, but this should be good for all relatively recent versions up to 2010 and probably 2013. There is no need to print each page one by one in the macro - just run it and then print the entire workbook. Change the value of StartPage if you want something other than page 33.

Code:
Sub RomanPageNums()
    Dim iPages As Integer
    Dim J As Integer
    Const Startpage As Integer = 33
    ' Get count of pages in active sheet
    iPages = ActiveWorkbook.Worksheets.Count
    ' Loop through all the pages
    For J = 1 To iPages
        ' Set page letter
        ActiveWorkbook.Worksheets(J).PageSetup.RightFooter = LCase(Application.Roman(J + Startpage - 1))
    Next J
End Sub

Regards

Murray
 
Upvote 0

Forum statistics

Threads
1,215,692
Messages
6,126,230
Members
449,303
Latest member
grantrob

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