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
 

Some videos you may like

Excel Facts

How can you turn a range sideways?
Copy the range. Select a blank cell. Right-click, Paste Special, then choose Transpose.

myall_blues

New Member
Joined
Nov 26, 2015
Messages
36
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
 

Watch MrExcel Video

Forum statistics

Threads
1,118,104
Messages
5,570,225
Members
412,311
Latest member
ncavana
Top