+ Reply to Thread
Results 1 to 11 of 11

Excel macro for printing multiple sheets...

  1. #1
    Registered User
    Join Date
    03-13-2008
    Posts
    3

    Excel macro for printing multiple sheets...

    Hi!

    Let's say I have a workbook containing of 10 sheets. I would like to create a macro that would allow me to do the following:

    Print sheet 1, 3 and 7. Always print sheet 1, however only print sheet 3 and 7 if there in these sheets are values in the cells from row 8 and below.

    (If that is to complicated it would be ok if the condition for printing sheet 3 and 7 is that there's a value in e.g. cell A8.)

    I managed to create this script that allows me to print sheets 1, 3 and 7, however I can't seem to find out where to put the if-statement (I suppose that's how you do it?). Here's the script i created so far:

    Please Login or Register  to view this content.
    I would really appriciate advice from you guys (and girls)

    Thank you!

    Kind regards,

    Nicklas
    Last edited by nicklas; 03-13-2008 at 07:12 AM.

  2. #2
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200
    Do an Advanced Search on my name with Print as the key word and you should find an example that should help
    Hope that helps.

    RoyUK
    --------
    For Excel Tips & Solutions, free examples and tutorials why not check out my web site

    Free DataBaseForm example

  3. #3
    Forum Moderator davesexcel's Avatar
    Join Date
    02-19-2006
    Location
    Regina
    MS-Off Ver
    MS 365
    Posts
    13,486
    Try hiding the sheets you do not want printed, then print the entire workbook
    example code
    Please Login or Register  to view this content.

  4. #4
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200
    Try this, note chane PrintPreview to Printout when you have finished testing.

    Please Login or Register  to view this content.
    Or

    Please Login or Register  to view this content.
    Last edited by royUK; 03-13-2008 at 08:44 AM.

  5. #5
    Forum Contributor
    Join Date
    02-27-2008
    Posts
    764

    macro

    Hi
    Try the following macro
    Please Login or Register  to view this content.
    Prints sheet1 and optionally 3 & 7 if A9 is not blank.
    Ravi

  6. #6
    Registered User
    Join Date
    03-13-2008
    Posts
    3
    Thank you royUK!!!! This worked excellent!

    Quote Originally Posted by royUK
    Try this, note chane PrintPreview to Printout when you have finished testing.

    Please Login or Register  to view this content.

  7. #7
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200
    Thanks for letting me know. Glad it helped.

  8. #8
    Registered User
    Join Date
    03-13-2008
    Posts
    3
    Just one last question though, what does this code in the script mean exactly?

    Please Login or Register  to view this content.
    Because when I tried to apply the macro where the cells have links in them but still equals zero it didn't work. For example: =Sheet5!A8 in one cell but A8 in Sheet5 is empty. The script worked when the cells being checked where completly empty but not when they contain references (although the reference cell is zero).

    Best regards,

    Nicklas

  9. #9
    Forum Contributor VBA Noob's Avatar
    Join Date
    04-25-2006
    Location
    London, England
    MS-Off Ver
    xl03 & xl 07(Jan 09)
    Posts
    11,988
    The line means if the Worksheets range A9 currentregion (see below) cells count is greater than 1 then worksheet print preview

    Currentregion
    (The current region is a range bounded by any combination of blank rows and blank columns)

    HTH

    VBA Noob
    _________________________________________


    Credo Elvem ipsum etian vivere
    _________________________________________
    A message for cross posters

    Please remember to wrap code.

    Forum Rules

    Please add to your signature if you found this link helpful. Excel links !!!

  10. #10
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200
    Empty cells are empty. Cells with links containing formulas are not empty, therefore they are part of the CurrentRegion. You would need to check for zero values, maybe

    Please Login or Register  to view this content.

  11. #11
    Registered User
    Join Date
    09-11-2012
    Location
    Lyon
    MS-Off Ver
    Excel 2010
    Posts
    1

    Re: Excel macro for printing multiple sheets...

    Thanks nice tip

+ 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