Forum Discussion
shetzel
Nov 06, 2023Copper Contributor
Print consecutive numbers from Excel
I have a template that auto fills data on how each part is configured on a cart and tells how many carts are needed based on order qty and would like it to print the cart number on each sheet. If I n...
- Nov 08, 2023
Try this version:
Sub PrintTags() Dim n As Long Dim i As Long n = Application.RoundUp(Range("B6").Value, 0) For i = 1 To n Range("B18").Value = i If i < n Then Range("B8").Value = Range("O9").Value Else Range("B8").Value = Range("P9").Value - (n - 1) * Range("O9").Value End If ActiveSheet.PrintOut Next i Range("B8,B18").ClearContents End Sub
HansVogelaar
Nov 08, 2023MVP
Try this version:
Sub PrintTags()
Dim n As Long
Dim i As Long
n = Application.RoundUp(Range("B6").Value, 0)
For i = 1 To n
Range("B18").Value = i
If i < n Then
Range("B8").Value = Range("O9").Value
Else
Range("B8").Value = Range("P9").Value - (n - 1) * Range("O9").Value
End If
ActiveSheet.PrintOut
Next i
Range("B8,B18").ClearContents
End Sub
shetzel
Nov 09, 2023Copper Contributor
Thank you very much for all of your help Hans. This works great.