Print Copies of Single Worksheet With Increment
Option Explicit
Sub PrintWithIncrement()
Const WORKSHEET_NAME As String = "Sheet1"
Const RANGE_ADDRESS As String = "C27,M27,C58,M58"
Const PROMPT As String = "Please enter the number of copies you want to print:"
Const TITLE As String = "Print With Increment"
Const DEFAULT_COPIES As Long = 1
Const MAX_COPIES As Long = 100
Const APPLY_TOTAL_LOGIC As Boolean = False
Dim pCount As Variant
Dim Msg As Long
Dim IsInputValid As Boolean
Do Until IsInputValid
pCount = Application.InputBox(PROMPT, TITLE, DEFAULT_COPIES, , , , , 1)
If VarType(pCount) = vbBoolean Then
MsgBox "Dialog canceled.", vbExclamation, TITLE
Exit Sub
End If
If Int(pCount) = pCount Then
If pCount > 0 Then IsInputValid = True
End If
If IsInputValid Then
If pCount > MAX_COPIES Then
Msg = MsgBox("This will print " & pCount & " copies." _
& vbLf & vbLf & "Are you sure?", _
vbQuestion + vbYesNo + vbDefaultButton2, TITLE)
If vbNo Then IsInputValid = False
End If
Else
MsgBox "lnvalid entry: " & pCount & vbLf & vbLf _
& "Try again.", vbExclamation, TITLE
End If
Loop
Application.ScreenUpdating = False
Dim wb As Workbook: Set wb = ThisWorkbook ' workbook containing this code
Dim ws As Worksheet: Set ws = wb.Sheets(WORKSHEET_NAME)
Dim rg As Range: Set rg = ws.Range(RANGE_ADDRESS)
rg.NumberFormat = "@"
Dim tCount As Long: tCount = pCount
If APPLY_TOTAL_LOGIC Then tCount = tCount * rg.Cells.Count
Dim cell As Range, p As Long, t As Long
For p = 1 To pCount
For Each cell In rg.Cells
t = t + 1
cell.Value = t & "/" & tCount
Debug.Print cell.Value ' Test with this first! Uncomment later!
'ws.PrintOut ' Out-comment when done testing!
Next cell
Next p
rg.ClearContents
Application.ScreenUpdating = True
MsgBox "Print job finished.", vbInformation, TITLE
End Sub
My Logic for 3 Copies (APPLY_TOTAL_LOGIC = TRUE)
1/12
2/12
3/12
4/12
5/12
6/12
7/12
8/12
9/12
10/12
11/12
12/12
Your Logic For 3 Copies (APPLY_TOTAL_LOGIC = FALSE)
1/3
2/3
3/3
4/3
5/3
6/3
7/3
8/3
9/3
10/3
11/3
12/3