1. Computer problem? Tech Support Guy is completely free -- paid for by advertisers and donations. Click here to join today! If you're new to Tech Support Guy, we highly recommend that you visit our Guide for New Members.

Creating a Macro in Excel: Date by addition when printing

Discussion in 'Business Applications' started by aem9266, Jun 18, 2017.

Thread Status:
Not open for further replies.
Advertisement
  1. aem9266

    aem9266 Thread Starter

    Joined:
    Jun 18, 2017
    Messages:
    5
    Good Morning,
    I am attempting to create a print preview, and then a printing button for one of my documents. I figured out how to do a basic print preview and then print when approved. If possible, I would like to create 5 copies (currently just pressing the button 5 times) and on each consecutive copy, have the date increase by one. I have the start date for printing appearing on a sheet called "WT" in cell C1 and would like it to appear in cell H1 for the worksheets ending in "SI" and then in cell AJ4 in worksheets ending in "TS". Not sure if this is possible, but any help would be greatly appreciated. I posted my current VPN coding for previewing and then printing these lists, but if you could help with one, I'm pretty sure I could figure out the other. Just please let me know if there are any changes in the "printout" phrases, please.
    Thanks for your help in advance



    Sub PrintPreviewCrewLists()
    Worksheets(Array("A SI", "A TS", "B SI", "B TS")).PrintOut Preview:=true
    For i = 1 To 5
    Range("H1") = Range("H1") + 1
    ActiveWindow.Worksheets(Array("A SI","B SI")).PrintPreview Copies:=1
    Next i
    For i = 1 To 5
    Range("AJ4") = Range("AJ4") + 1
    ActiveWindow.Worksheets(Array("A TS", "B TS")).PrintPreview Copies:=1
    Next i
    End Sub

    Printing macro has not been updated as I have not figured out how to preview it successfully.

    Sub PrintCrewLists()
    Worksheets(Array("A SI", "A TS", "B SI", "B TS")).PrintOut
    End Sub
     
  2. Keebellah

    Keebellah Trusted Advisor

    Joined:
    Mar 27, 2008
    Messages:
    6,351
    Hi, you write a loop that runs 5 times, something like this

    Code:
    Sub PrintFiveTimes()
    Dim pLoop as Integer
    for pLoop = 1 to 5
         Range("H1") = Range("H1") + 1
        ActiveWindow.Worksheets(Array("A SI","B SI")).PrintPreview Copies:=1
       Range("AJ4") = Range("AJ4") + 1
       ActiveWindow.Worksheets(Array("A TS", "B TS")).PrintPreview Copies:=1
    next pLoop
    End Sub
     
  3. Keebellah

    Keebellah Trusted Advisor

    Joined:
    Mar 27, 2008
    Messages:
    6,351
    I don't know why the preview, but...
     
As Seen On
As Seen On...

Welcome to Tech Support Guy!

Are you looking for the solution to your computer problem? Join our site today to ask your question. This site is completely free -- paid for by advertisers and donations.

If you're not already familiar with forums, watch our Welcome Guide to get started.

Join over 733,556 other people just like you!

Loading...
Thread Status:
Not open for further replies.

Short URL to this thread: https://techguy.org/1191668