Auto increment on print function

Jay125950

New Member
Joined
Mar 31, 2021
Messages
3
Office Version
  1. 2019
Platform
  1. Windows
Hello, i am trying to find a way that i can apply code to a workbook that automatically counts up +1 every time i print the document, I have an invoice i have generated and when i sit down and do multiple at a time it would save me a lot of headache if i hit print and it automatically increased box F5 from 000 to 001 etc.

Thanks in advance for any help!
 

Excel Facts

Easy bullets in Excel
If you have a numeric keypad, press Alt+7 on numeric keypad to type a bullet in Excel.
try this. this will print and change the value of F5 every time it prints. Note the the format of the Cell needs to be Custom to be "000"

VBA Code:
Sub PrintInvoice()
Dim x As Integer
Dim c As Variant
c = InputBox("NUMBER OF COPIES", "PRINT")
For x = 1 To c
    Range("F5").Value = x
    Sheet1.PrintOut
      Next x
MsgBox "DONE PRINTING", vbOKOnly, "PRINT COMPLETED"
End Sub

try with entering low number as a test.
 
Upvote 0
Every time I run this it just "resets" the vtalue to "1" as apposed to incrementing by 1, as a test I manually entered random numbers as the value in the format of "005, 009, etc." and when I run the print function it changes it to "1"
 
Upvote 0
Try this:
VBA Code:
Sub PrintInvoice()
Dim x As Integer
Dim c As Variant
c = InputBox("NUMBER OF COPIES", "PRINT")
For x = 1 To c
    Range("F5").Value = Range("F5").Value + 1
    Sheet1.PrintOut
      Next x
MsgBox "DONE PRINTING", vbOKOnly, "PRINT COMPLETED"
End Sub
 
Upvote 0
try this. this will print and change the value of F5 every time it prints. Note the the format of the Cell needs to be Custom to be "000"

VBA Code:
Sub PrintInvoice()
Dim x As Integer
Dim c As Variant
c = InputBox("NUMBER OF COPIES", "PRINT")
For x = 1 To c
    Range("F5").Value = x
    Sheet1.PrintOut
      Next x
MsgBox "DONE PRINTING", vbOKOnly, "PRINT COMPLETED"
End Sub

try with entering low number as a test.
Is it possible to use this same idea, but have it work across a second sheet? Then when you print, it prints sheet1, sheet2, then changes the number?
 
Upvote 0
Assuming value in both sheets are in F5. I have not test this but try this

VBA Code:
Sub PrintInvoice()
Dim x As Integer
Dim c As Variant
c = InputBox("NUMBER OF COPIES", "PRINT")
For x = 1 To c
    Sheet1.Range("F5").Value = x
    Sheet1.PrintOut
    Sheet2.Range("F5").Value = x
    Sheet2.printout
      Next x
MsgBox "DONE PRINTING", vbOKOnly, "PRINT COMPLETED"
End Sub
 
Upvote 0
I would do another For statement if you have a lot of Sheets to loop through. That’s just for 2 sheets
 
Upvote 0

Forum statistics

Threads
1,224,826
Messages
6,181,192
Members
453,021
Latest member
pingpong7117

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