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
 

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
 

Forum statistics

Threads
1,082,323
Messages
5,364,589
Members
400,808
Latest member
formulasataglance

Some videos you may like

This Week's Hot Topics

  • populate from drop list with multiple tables
    Hi All, i have a drop list that displays data, what i want is when i select one of those from the list to populate text from different tables on...
  • Find list of words from sheet2 in sheet1 before a comma and extract text vba
    Hi Friends, Trying to find the solution on my task. But did not find suitable one to the need. Here is my query and sample file with details...
  • Dynamic Formula entry - VBA code sought
    Hello, really hope one of you experts can help with this - i've spent hours on this and getting no-where. .I have a set of data (more rows than...
  • Listbox Header
    Have a named range called "AccidentsHeader" Within my code I have: [CODE]Private Sub CommandButton1_Click() ListBox1.RowSource =...
  • Complex Heat Map using conditional formatting
    Good day excel world. I have a concern. Below link have a list of countries that carries each country unique data. [URL...
  • Conditional formatting
    Hi good morning, hope you can help me please, I have cells P4:P54 and if this cell is equal to 1 then i want row O to say "Fully Utilised" and to...
Top