Continuous numbering macro

BON13

New Member
Joined
Feb 10, 2022
Messages
2
Office Version
  1. 365
Platform
  1. Windows
Hi,

I'm looking for some help with continuous numbering. I want to print a sheet which will auto update the numbers down the side when I print multiple sheets. I have managed to do it with a macro to print continuous page numbers from the one sheet, but I'm getting stuck when it comes to multiple numbers. does that make any sense? Any help with a macro to achieve this?

Cheers!
Excel Help.png
 

Excel Facts

Highlight Duplicates
Home, Conditional Formatting, Highlight Cells, Duplicate records, OK to add pink formatting to any duplicates in selected range.
You have 1 sheet that you want to number every other row with 1 to 12 in column A and print that, then renumber from 13 to 25 and print that, then ... and so on? What decides the number of times to print the sheet?
 
Upvote 0
You have 1 sheet that you want to number every other row with 1 to 12 in column A and print that, then renumber from 13 to 25 and print that, then ... and so on? What decides the number of times to print the sheet?
Pretty much, yes. The macro I'm using for numbering the sheet asks me how many pages I want to print. When I run the macro and input 10, it will print 10 pages, numbered 1 - 10 in cell A48. Instead of page numbers, I'd like to do something similar but will all the cells in column A. page 1 numbered 1 - 12. page 2, 13 - 24 and so on.

Macro I'm using for page numbers is below:

Sub IncrementPrint()
Dim xCount As Variant
Dim xScreen As Boolean
Dim I As Long
Dim xM As Long
Dim xMNWS As Worksheet
Dim xAWS As Worksheet
On Error Resume Next
LInput:
xCount = Application.InputBox("Please enter the number of copies you want to print:", "Kutools for Excel")
If TypeName(xCount) = "Boolean" Then Exit Sub
If (xCount = "") Or (Not IsNumeric(xCount)) Or (xCount < 1) Then
MsgBox "error entered, please enter again", vbInformation, "Kutools for Excel"
GoTo LInput
Else
xScreen = Application.ScreenUpdating
Set xAWS = ActiveSheet
On Error GoTo EMarkNumberSheet
Set xMNWS = Sheets("IncrementPrint_MarkNumberSheet")
EMarkNumberSheet:
If xMNWS Is Nothing Then
Set xMNWS = Application.Worksheets.Add(Type:=xlWorksheet)
xMNWS.Name = "IncrementPrint_MarkNumberSheet"
xMNWS.Range("A48").Value = 0
xM = 0
xMNWS.Visible = xlSheetVeryHidden
Else
xM = xMNWS.Range("A48").Value
End If
Application.ScreenUpdating = False
For I = 1 To xCount
xM = xM + 1
xAWS.Range("A48").Value = " Page 00" & xM
xAWS.PrintOut
Next
xMNWS.Range("A48").Value = xM
xAWS.Range("A48").ClearContents
Application.ScreenUpdating = xScreen
End If
End Sub
 
Upvote 0
What I had, edited to include your input box (no verification that it's a valid number but you can add that?). Also this prints one sheet n times, not n sheets once each.
Assuming row numbers to be entered start at A12 and skip every other row, consider
VBA Code:
Sub NumberPrint()
Dim i As Integer, c As Integer, x As Integer, n As Integer

n =  Application.InputBox("Please enter the number of copies you want to print:", "Kutools for Excel")

For x = 1 To n
   For i = 12 To 34 Step 2 'the range in column A to write to
     With Sheets("SheetNameHere")
       .Range("A" & i) = c + 1 ' add 1 to c and write that to cell
       '.PrintOut
       MsgBox "A" & i & "   " & c + 1
        c = c + 1
     End With
   Next
Next

End Sub
You should use vba code tags with proper indentation to make it easier to read and/or troubleshoot. Get rid of the message box line if it does what you want, and turn on the print line.
 
Last edited:
Upvote 0
You might need a pause or Do Events to allow numbering to take place properly between printouts. I didn't test printing.
 
Upvote 0

Forum statistics

Threads
1,214,523
Messages
6,120,034
Members
448,940
Latest member
mdusw

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