Results 1 to 3 of 3
  1. #1
    Star Lounger
    Join Date
    Jul 2006
    Posts
    71
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Run Multiple Macros (2003)

    I am wondering whether it's possible to set up a command to run two sets of instructions successively.

    I have at this moment a spreadsheet with one macro button for Print Preview (there's some processing beforehand) and a second button linked to a second macro for Print. The macros are identical until they come to either Print Preview OR Print and then they converge again in the final instructions. Any tweaking -- and there has been some -- needs to be done to each macro. Possibly an If-Then-Else could achieve some efficiency?

    Someone must have needed to do this at some point ....

    Hopefully,

    Ann

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Run Multiple Macros (2003)

    You could do something like this:

    Sub MyMacro(Preview As Boolean)
    ...
    ...
    If Preview Then
    ActiveSheet.PrintPreview
    Else
    ActiveSheet.PrintOut
    End If
    ...
    ...
    End Sub

    Sub MyPrint()
    MyMacro False
    End Sub

    Sub MyPreview()
    MyMacro True
    End Sub

    MyPrint and MyPreview would be the macros called from the buttons. Both call MyMacro, but with a different value for the Preview argument. You only need to tweak MyMacro if you want to change the code.

  3. #3
    Star Lounger
    Join Date
    Jul 2006
    Posts
    71
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Re: Run Multiple Macros (2003)

    How elegant!

    Thank you very much!

    Ann

Posting Permissions

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