+ Reply to Thread
Results 1 to 6 of 6

Macro for printing

  1. #1
    Registered User
    Join Date
    12-13-2009
    Location
    Indiana
    MS-Off Ver
    Excel 2003
    Posts
    12

    Macro for printing

    I am new to VBA programing. I am creating a macro in Excel 2003 to print multiple copies. Specifically, I want the number of copies to be equal to the value located in a certain cell in the worksheet. Any advice?

    The Excel printer code looks like this.

    ActiveWindow.SelectedSheets.PrintOut Copies:=1, Collate:=True
    Last edited by Dave7554; 12-19-2009 at 06:33 AM.

  2. #2
    Forum Expert teylyn's Avatar
    Join Date
    10-28-2008
    Location
    New Zealand
    MS-Off Ver
    Excel 365 Insider Fast
    Posts
    11,372

    Re: Need help with macro for printing

    Hi Dave7554,

    welcome to the forum. I'm sure one of the VBA wizards will pick up your question soon.

    In the meantime, please have a look at the forum rules to get a feel for how this forum is run. Please try to avoid words like "help" in the title of your thread. Since everyone asking here is looking for help, words like that don't add value.

    If you want to post more than one line of code, make sure to use code tags like this [code]Please [url=https://www.excelforum.com/login.php]Login or Register [/url] to view this content.[/code]. That will make code easier to read and copy for testing.

    I'm sure you'll find lots of valuable assistance here, so please stick around..

    cheers

  3. #3
    Forum Expert
    Join Date
    01-03-2006
    Location
    Waikato, New Zealand
    MS-Off Ver
    2010 @ work & 2007 @ home
    Posts
    2,243

    Re: Macro for printing

    hi Dave7554,

    Welcome to the forum

    Try something like this...
    Please Login or Register  to view this content.
    Edit: Note there is no error checking in my example to make sure that the value in the specific cell is numeric.


    hth
    Rob
    Last edited by broro183; 12-14-2009 at 05:04 PM.
    Rob Brockett
    Kiwi in the UK
    Always learning & the best way to learn is to experience...

  4. #4
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: Macro for printing

    Broro, what's the reason for using the MAX function with only one cell in question?
    _________________
    Microsoft MVP 2010 - Excel
    Visit: Jerry Beaucaire's Excel Files & Macros

    If you've been given good help, use the icon below to give reputation feedback, it is appreciated.
    Always put your code between code tags. [CODE] your code here [/CODE]

    ?None of us is as good as all of us? - Ray Kroc
    ?Actually, I *am* a rocket scientist.? - JB (little ones count!)

  5. #5
    Forum Expert
    Join Date
    01-03-2006
    Location
    Waikato, New Zealand
    MS-Off Ver
    2010 @ work & 2007 @ home
    Posts
    2,243

    Re: Macro for printing

    hi JB,

    I'm not connected to a printer (& had forgotten the syntax for printpreview) so I included the max function just in case there was no value in the specific cell (which may (?) cause the code to error).
    It probably can/should be checked differently using If, Iif or some other ">0" check but ".Max" came into my head first as I was typing

    Your curiosity made me check my facts & the Excel 2007 Help file states
    The number of copies to print. If this argument is omitted, one copy is printed.
    (I'm assuming this hasn't changed since earlier versions). With this in mind, there probably isn't the need for .max or another >0 check, only for a numeric check.

    Rob

  6. #6
    Registered User
    Join Date
    12-13-2009
    Location
    Indiana
    MS-Off Ver
    Excel 2003
    Posts
    12

    Re: Macro for printing

    Rob,
    Thanks for the code. I will try it out this weekend. This will be key to my project.
    Dave

+ 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