+ Reply to Thread
Results 1 to 5 of 5

Printing Macro-Is there anyway I can use a macro that will print only

  1. #1
    Registered User
    Join Date
    08-27-2004
    Posts
    40

    Printing Macro-Is there anyway I can use a macro that will print only

    Hi

    I have a workbook with approximately 45 worksheets. Each worksheet is a weekly job list for employees. Currently we print the entire workbork, but if the employee in question has no work it simply prints off a blank sheet with just his/hers name at the top.

    Is there anyway I can use a macro that will print only those worksheets that e.g. only have data in cell A2 (this would mean they have jobs for the week). We're just trying to save some paper and are too lazy to print the worksheets individually

    Any help would be really appreciated.

    Thanks

    Darren

  2. #2
    Forum Contributor stevebriz's Avatar
    Join Date
    09-07-2006
    Location
    Santiago Chile
    Posts
    389
    You can try this.

    Please Login or Register  to view this content.
    VBA - The Power Behind the Grid

    Posting a sample of your workbook makes it easier to look at the Issue.

  3. #3
    Forum Contributor colofnature's Avatar
    Join Date
    05-11-2006
    Location
    -
    MS-Off Ver
    -
    Posts
    301
    Try this:

    sub print_sheets()
    dim ws as worksheet
    for each ws in worksheets
    if ws.[a2].value <> empty then ws.select replace:=false
    next
    activewindow.selectedsheets.printout copies:=1
    end sub


    HTH
    Col

  4. #4
    Forum Contributor colofnature's Avatar
    Join Date
    05-11-2006
    Location
    -
    MS-Off Ver
    -
    Posts
    301
    Actually, my last post will print whichever sheet(s) happens to be selected when the macro is run as well as the ones you need. To avoid this, add a blank sheet to the workbook with the button to run your macro on it and use this variation:

    sub print_sheets_2()
    dim ws as worksheet
    dim first as boolean
    first = true
    for each ws in worksheets
    if ws.[a2].value <> empty then
    if first then
    ws.select replace:=true
    first = false
    else
    ws.select replace:=false
    end if
    end if
    next
    activewindow.selectedsheets.printout copies:=1
    end sub


    Col

  5. #5
    Registered User
    Join Date
    08-27-2004
    Posts
    40
    Fantastic!

    Thanks ever so much.

    Darren

+ 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