Advance date by one after each printed copy

BJTred

New Member
Joined
May 30, 2018
Messages
8
Is it possible to have Excel advance the date by one for each copy of the workbook I print? I have a workbook with names on it, used to sign out equipment. The workbook has 6 separate sheets in it. I have the date in one cell on each sheet (it's the same cell on each sheet). Currently I print one copy, change the date on all 6 sheets (using find and replace), then print, change the date on all 6 sheets, then print, and so on and so on. Is there a way to automate this, so that I can put in the start date, tell it I want 30 copies and it will change the date (on all 6 sheets) after it prints each copy? Hope that makes sense.Thanks.BJTred
 

Excel Facts

How can you automate Excel?
Press Alt+F11 from Windows Excel to open the Visual Basic for Applications (VBA) editor.
You can do it before you print, which is essentially the same thing after the first time :) . Don't know your sheet names or ranges but try something like this:

Code:
Private Sub Workbook_BeforePrint(Cancel As Boolean)
    Worksheets("Sheet1").Range("A1").Value = Worksheets("Sheet1").Range("A1").Value + 1
End Sub

By the way, that goes into the workbook code module.
 
Last edited:
Upvote 0
That Workbook_BeforePrint code would require the user to manually print each copy.

Try this instead (code in a standard module and A2 in every sheet is the date cell).
Code:
Public Sub Print_Workbook_Multiple_Copies()

    Dim startDate As String, numCopies As String
    Dim ws As Worksheet, n As Long
    
    startDate = InputBox("Start date")
    If startDate = "" Then Exit Sub
    numCopies = InputBox("Number of copies")
    If numCopies = "" Then Exit Sub
    
    For n = 1 To numCopies
        For Each ws In ThisWorkbook.Worksheets
            ws.Range("A2").Value = CDate(startDate) + n - 1
        Next
        ThisWorkbook.PrintOut Copies:=1, Collate:=True, IgnorePrintAreas:=False
    Next
    
End Sub
 
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,170
Members
453,021
Latest member
Justyna P

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