Changing Cell Values while Printing

Written by Allen Wyatt (last updated September 18, 2021)
This tip applies to Excel 2007, 2010, 2013, 2016, 2019, and Excel in Microsoft 365


2

Madhabi wants to print four copies of a worksheet, but have the value of cell A7 change for each copy. The four values are "Original," "Duplicate," "File," and "Driver." All other data being the same, Madhabi wonders how he can change the text of cell A7 while printing.

One possible approach is to create four different worksheets that contain essentially the same information. Worksheets 2 through 4 could all reference cells on worksheet 1, with the exception of cell A7 which could be set on each worksheet to a different value ("Original," "Duplicate," etc.).

A better approach, however, would be to create a quick macro that you could use for your printing. The macro could handle changing the value of cell A7 just before the worksheet is printed each time. Here's a simple example:

Sub PrintCopies()
    Dim i As Integer
    Dim VList As Variant

    VList = Array("Original", "Duplicate", "File", "Driver")
    For i = LBound(VList) To UBound(VList)
        Range("A7") = VList(i)
        ActiveSheet.PrintOut 
    Next
End Sub

The macro places the four values destined for cell A7 into an array. The macro then steps through each of the four array elements, putting the value into cell A7, and then printing the worksheet. Printing is done to whatever the default printer is on the system.

The macro could easily be assigned to a shortcut key or to the Quick Access Toolbar (as described in other ExcelTips) so that it you could print all four copies quickly.

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 (9962) applies to Microsoft Excel 2007, 2010, 2013, 2016, 2019, and Excel in Microsoft 365.

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

Page Layout Zoom Settings

The zoom setting at which you view a document can sometimes be saved with a document. This tip explains how the zoom ...

Discover More

Viewing Comments

There are three different ways that Excel allows you to display any comments that are in your worksheet. Here's how you ...

Discover More

Creating a Table of Authorities

In legal documents a table of authorities is a common element. Creating the table is easy to do if you apply the ...

Discover More

Excel Smarts for Beginners! Featuring the friendly and trusted For Dummies style, this popular guide shows beginners how to get up and running with Excel while also helping more experienced users get comfortable with the newest features. Check out Excel 2013 For Dummies today!

More ExcelTips (ribbon)

Printing Gridlines by Default

When you print a worksheet, Excel allows you to also print handy gridlines for the worksheet. If you want to include the ...

Discover More

Adding Page Borders to a Printout

Need a full-page border on your Excel printouts? It's not as easy to get one as you might wish. There are a few ways you ...

Discover More

Printing a List of Named Ranges

You already know that you can define names that apply to different ranges of cells and other elements such as formulas. ...

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}] (all 7 characters, in the sequence shown) 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 6 - 6?

2021-10-27 10:25:01

J. Woolley

@Andrew
Put the number of copies in cell A7, then run this:

Sub PrintCopies()
ActiveSheet.PrintOut Copies:=[A7]
End Sub

Also, see https://sites.google.com/view/MyExcelToolbox/


2021-10-26 13:32:56

Andrew

This is great! How would you go about printing out as many sheets as the number in a cell. Lets say the number in the cell was 3. The macro would then print out 3 copies of the sheet.


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.