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

Formatting Lots of Tables

Do you need a quick way to format your tables? Believe it or not, there are several tools you can use from Word's arsenal ...

Discover More

Copying a Hyperlink to Lots of Worksheets

Copying information from one place to another in a worksheet is easy. Copying hyperlinks may not seem that easy, but you ...

Discover More

Finding the Dates for Minimums and Maximums

If you use Excel to maintain a collection of data, you may need to find information in one column based on information in ...

Discover More

Save Time and Supercharge Excel! Automate virtually any routine task and save yourself hours, days, maybe even weeks. Then, learn how to make Excel do things you thought were simply impossible! Mastering advanced Excel macros has never been easier. Check out Excel 2010 VBA and Macros today!

More ExcelTips (ribbon)

Creating Individual PDFs by Worksheet

Want to print your worksheets to their own PDF? This can be quite manually intensive, unless you put the macro in this ...

Discover More

Printing Columns and Rows

If you want to print just the contents of a number of rows and columns, it can be challenging to get the output you want. ...

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 eight minus 8?

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.