+ Reply to Thread
Results 1 to 7 of 7

Macros or VB Code for printing a sheet and then automatically changing the date by 1d

Hybrid View

  1. #1
    Registered User
    Join Date
    01-06-2009
    Location
    calgary, alberta, canada
    MS-Off Ver
    Excel 2003
    Posts
    7

    Macros or VB Code for printing a sheet and then automatically changing the date by 1d

    Hi there,

    I am looking for a code or macros that would print the current sheet then change the date in a specific cell 'B3' by one day before printing again for that day and so on and so forth...

    Thanks in advance for any replies!

  2. #2
    Forum Moderator davesexcel's Avatar
    Join Date
    02-19-2006
    Location
    Regina
    MS-Off Ver
    MS 365
    Posts
    13,525

    Re: Macros or VB Code for printing a sheet and then automatically changing the date b

    Try this
        ActiveSheet.PrintOut
        Range("B3") = Range("B3") + 1

  3. #3
    Forum Expert
    Join Date
    10-06-2008
    Location
    Canada
    MS-Off Ver
    2007 / 2013
    Posts
    5,692

    Re: Macros or VB Code for printing a sheet and then automatically changing the date b

    You don't specify how many copies you want to print, if known at all.
    As long as you select Yes on the Message Box it will continue with printing with the next date.


    Sub NextDate()
        Dim j As Integer
        Dim Msg, Style, Title, Response, MyString
        Msg = "Do you want to continue ?"
        Style = vbYesNo + vbCritical
        Title = "More printing?"
        j = 0
        Do
            ActiveSheet.PrintPreview  '<----- Change to Print the page or area
            Response = MsgBox(Msg, Style, Title)
            If Response = vbNo Then
                Exit Sub
            Else
                j = j + 1
                Range("B3").Formula = "=TODAY() + " & j
            End If
        Loop
    End Sub
    Try it on a copy of your workbook.

    BTW, are you an Oiler fan now after the last game?

    I guess your neighbour (Dave) has an easier solution
    Last edited by jolivanes; 02-26-2012 at 05:09 PM. Reason: Saw Dave's post after

  4. #4
    Forum Moderator davesexcel's Avatar
    Join Date
    02-19-2006
    Location
    Regina
    MS-Off Ver
    MS 365
    Posts
    13,525

    Re: Macros or VB Code for printing a sheet and then automatically changing the date b

    Your asking a guy from Calgary if he is an Oiler Fan?

  5. #5
    Forum Expert
    Join Date
    10-06-2008
    Location
    Canada
    MS-Off Ver
    2007 / 2013
    Posts
    5,692

    Re: Macros or VB Code for printing a sheet and then automatically changing the date b

    Well Dave, with all respect, some people see the light (as it looks like, in the future)

  6. #6
    Forum Expert
    Join Date
    10-06-2008
    Location
    Canada
    MS-Off Ver
    2007 / 2013
    Posts
    5,692

    Re: Macros or VB Code for printing a sheet and then automatically changing the date b

    @visi

    If you want to use the code I supplied, you should add

        Range("B3").Formula = "=TODAY()"
    between Title = "More printing?" and j = 0

    This will set the date to the date when you run it anew.

    Good luck with the Flames as they can still make the playoffs. Hope they do. Our team won't.

  7. #7
    Registered User
    Join Date
    01-06-2009
    Location
    calgary, alberta, canada
    MS-Off Ver
    Excel 2003
    Posts
    7

    Re: Macros or VB Code for printing a sheet and then automatically changing the date b

    Thank you so much for the replies guys. This worked great! and sorry not an Edmonton fan at all!

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1