Please Note: This article is written for users of the following Microsoft Excel versions: 2007, 2010, and 2013. If you are using an earlier version (Excel 2003 or earlier), this tip may not work for you. For a version of this tip written specifically for earlier versions of Excel, click here: Printing Only Non-Blank Worksheets.

Printing Only Non-Blank Worksheets

by Allen Wyatt
(last updated August 3, 2018)

7

Clinton has a workbook containing over 200 worksheets that get populated by various people in his company during the month. At the end of the month he needs to print these worksheets. Not all the worksheets contain data and Clinton only wants to print the worksheets that contain data so he doesn't waste paper. He wonders if there is, perhaps, a macro that he can use to print only those worksheets that have a value in cell G41.

The answer is that such a macro could be written rather easily. It would only need to figure out how many worksheets there are, check cell G41 on each of them, and then print only if there is something in that cell. The following macro performs just these operations.

Sub PrintMost()
    Dim wks As Worksheet
    For Each wks In ActiveWorkbook.Worksheets
        If Not IsEmpty(wks.Range("G41")) Then
            wks.PrintOut
        End If
    Next
    Set wks = Nothing
End Sub

The macro could be easily modified to perform other operations, such as asking if any given worksheet should be printed or asking how many copies should be printed.

Note:

If you would like to know how to use the macros described on this page (or on any other page on the ExcelTips sites), I've prepared a special page that includes helpful information. Click here to open that special page in a new browser tab.

ExcelTips is your source for cost-effective Microsoft Excel training. This tip (10819) applies to Microsoft Excel 2007, 2010, and 2013. You can find a version of this tip for the older menu interface of Excel here: Printing Only Non-Blank Worksheets.

Author Bio

Allen Wyatt

With more than 50 non-fiction books and numerous magazine articles to his credit, Allen Wyatt is an internationally recognized author. He is president of Sharon Parq Associates, a computer and publishing services company. ...

MORE FROM ALLEN

Margin Notes in Word

Some types of documents rely upon margin notes to the left or right of your main text. Getting these to appear in Word ...

Discover More

Using Last-page Headers and Footers

Headers and footers add a nice touch to your documents, particularly if they are printed. You may want Word to use a ...

Discover More

Printing Only Selected Pages

When you print a worksheet, you don't need to print the whole thing. You can print only the pages you want. Here's how to ...

Discover More

Program Successfully in Excel! John Walkenbach's name is synonymous with excellence in deciphering complex technical topics. With this comprehensive guide, "Mr. Spreadsheet" shows how to maximize your Excel experience using professional spreadsheet application development tips from his own personal bookshelf. Check out Excel 2013 Power Programming with VBA today!

More ExcelTips (ribbon)

Specifying a Print Tray for a Worksheet

If you need to modify where a worksheet is printed (meaning, which paper tray it should use), Excel doesn't provide a lot ...

Discover More

Changing Paper Size for a Complete Workbook

If you need to change the size of paper on which your worksheets will be printed, it can be bothersome to make the change ...

Discover More

Automatically Printing a Range

If you want to automatically print a particular area of your worksheet at a specific time of day, you'll love this tip. ...

Discover More
Subscribe

FREE SERVICE: Get tips like this every week in ExcelTips, a free productivity newsletter. Enter your address and click "Subscribe."

View most recent newsletter.

Comments

If you would like to add an image to your comment (not an avatar, but an image to help in making the point of your comment), include the characters [{fig}] in your comment text. You’ll be prompted to upload your image when you submit the comment. Maximum image size is 6Mpixels. Images larger than 600px wide or 1000px tall will be reduced. Up to three images may be included in a comment. All images are subject to review. Commenting privileges may be curtailed if inappropriate images are posted.

What is 8 + 1?

2018-08-04 09:31:03

Willy Vanhaelen

@Steve
In this case Set wks = Nothing is superfluous. The purpose is to free memory taken by the the variable wks. But since the macro terminates after this, all memory used by it is freed anyway. So you can delete it safely.


2018-08-03 08:54:00

Steve Givens

Help@ What is the need for the last line of code Set wks = Nothing ? What could be the consequence of not including it?


2015-05-22 15:58:49

Willy Vanhaelen

@Rick Sullivan
You just save time because printing an empty page doesn't waist toner nor paper because it's just an empty page and you can reuse it :-)


2015-05-21 12:36:51

Rick Sullivan

Wow. I was searching the web for a solution to my printing woes and this solved my problem perfectly. No more wasted paper and toner.


2015-01-26 12:10:11

Johnny

Is there a way to accomplish this without using a macro? For instance, designate a cell on each worksheet that, if selected, would include the page in the print job and if left unselected it would exclude it from the print job when printing the entire workbook?


2015-01-19 09:23:55

Dennis Costello

I wonder if each of the PrintOut actions would cause a separate print job? If so, each is likely to have its own flag page(s) - there goes the paper savings.


2015-01-19 09:21:56

Dennis Costello

I wonder if following this approach would lead to each of the worksheets (tabs) being its own separately-queued print job? If so, they're likely to end up with separate flag pages for each worksheet (instead of one set for the the entire set of worksheets) - this would not fit well with the paper-savings goal.


This Site

Got a version of Excel that uses the ribbon interface (Excel 2007 or later)? This site is for you! If you use an earlier version of Excel, visit our ExcelTips site focusing on the menu interface.

Newest Tips
Subscribe

FREE SERVICE: Get tips like this every week in ExcelTips, a free productivity newsletter. Enter your address and click "Subscribe."

(Your e-mail address is not shared with anyone, ever.)

View the most recent newsletter.