Written by Allen Wyatt (last updated November 21, 2023)
This tip applies to Excel 2007, 2010, 2013, 2016, 2019, and 2021
Henry would like a cell to contain a number that increments every time a copy of the worksheet is printed. Thus, if the cell contains the number 9 and he prints 13 copies of the worksheet, each copy would contain, in that cell, the numbers 9, 10, 11, and on through 21.
This, as you might guess, is best done with a macro. All that needs to be done is to print the worksheet however many times is desired, incrementing the value of the cell after each print. In this case, I'm going to assume that the cell to be incremented is B7. The following macro will handle the process:
Sub PrintNumberedCopies()
Dim iCopies As Integer
Dim J As Integer
Dim r As Range
' Specify the cell to modify
Set r = Range("B7")
' Get the number of copies.
iCopies = Val(InputBox("Number of copies to print:"))
If iCopies > 0 Then
' Loop iCopies times, printing once per loop
For J = 1 to iCopies
ActiveSheet.PrintOut
r.Value = r.Value + 1
Next J
End If
End Sub
Note that the macro asks the user how many copies to print, and then it goes about printing each one, individually. After each printout, it increments the value stored in cell B7. If the user enters something that does not translate to a number of copies, then nothing is printed.
Remember that if you want the value number in B7 to always be up to date, you'll need to save the workbook sometime after your last printing. In addition, if you print using some method other than this macro, then the value in B7 will not reflect the number of actual copies printed.
Note:
ExcelTips is your source for cost-effective Microsoft Excel training. This tip (12135) applies to Microsoft Excel 2007, 2010, 2013, 2016, 2019, and 2021.
Dive Deep into Macros! Make Excel do things you thought were impossible, discover techniques you won't find anywhere else, and create powerful automated reports. Bill Jelen and Tracy Syrstad help you instantly visualize information to make it actionable. You’ll find step-by-step instructions, real-world case studies, and 50 workbooks packed with examples and solutions. Check out Microsoft Excel 2019 VBA and Macros today!
Would you like to have a worksheet automatically printed when a particular cell contains a specified value? You can ...
Discover MoreNeed to print a portion of a worksheet, but don't want to waste paper by printing the whole thing? It's easy to print ...
Discover MoreWhen you accumulate quite a few workbooks in a folder, you might need to print out selected worksheets from all of the ...
Discover MoreFREE SERVICE: Get tips like this every week in ExcelTips, a free productivity newsletter. Enter your address and click "Subscribe."
2023-08-08 15:06:55
Marc
Thanks, Allan. Works great.
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.
FREE SERVICE: Get tips like this every week in ExcelTips, a free productivity newsletter. Enter your address and click "Subscribe."
Copyright © 2025 Sharon Parq Associates, Inc.
Comments