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

Full Path Names in Headers or Footers

Using a macro to add the full path name into a header or footer in an Excel worksheet.

Discover More

Printing a Document's Mirror Image

If you need to print the mirror image (backwards) of a document, you may think you are out of luck in Word. There are ...

Discover More

Counting Asterisks

For some operations and functions, Excel allows you to use wild card characters. One such character is an asterisk. What ...

Discover More

Comprehensive VBA Guide Visual Basic for Applications (VBA) is the language used for writing macros in all Office programs. This complete guide shows both professionals and novices how to master VBA in order to customize the entire Office suite for their needs. Check out Mastering VBA for Office 2010 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

Out of Kilter Borders

Borders not printing properly? It could be any one of a number of reasons causing the problem. This tip provides some ...

Discover More

Printing a Draft Watermark

Adding a watermark to the background of a printout can be challenging. This tip explains the different ways you can ...

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 five less than 7?

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.