Tip: Other languages are Google-Translated. You can visit the English version of this link.
Log in
x
or
x
x
Register
x

or

 How to auto increment cell value after each printing?

Supposing, I have a worksheet page needed to be printed 100 copies, the cell A1 is the check number Company-001, now, I would like the number will increase by 1 after every printout. That means when I print the second copy, the number will be increased to Company-002 automatically, the third copy, the number will be Company-003…one hundred copy, the number will be Company-100. Is there any trick to solve this problem in Excel quickly and possibly?

Auto increment cell value after each printing with VBA code


Print odd, even, current, or specified pages of a worksheet

Kutools for Excel's Print Specified Pages utility can help you to quickly print odd, even, current or specified pages as you need.

doc increment when printting 2

Kutools for Excel: with more than 200 handy Excel add-ins, free to try with no limitation in 60 days. Download and free trial Now!


arrow blue right bubble Auto increment cell value after each printing with VBA code


Normally, there is no direct way for you to solve this task in Excel, but, here, I will create a VBA code to deal with it.

1. Hold down the ALT + F11 keys to open the Microsoft Visual Basic for Applications window.

2. Click Insert > Module, and paste the following code in the Module Window.

VBA code: Auto increment cell value after each printing:

Sub IncrementPrint()
'updateby Extendoffice 20160530
    Dim xCount As Variant
    Dim xScreen As Boolean
    Dim I As Long
    On Error Resume Next
LInput:
    xCount = Application.InputBox("Please enter the number of copies you want to print:", "Kutools for Excel")
    If TypeName(xCount) = "Boolean" Then Exit Sub
    If (xCount = "") Or (Not IsNumeric(xCount)) Or (xCount < 1) Then
        MsgBox "error entered, please enter again", vbInformation, "Kutools for Excel"
        GoTo LInput
    Else
        xScreen = Application.ScreenUpdating
        Application.ScreenUpdating = False
        For I = 1 To xCount
            ActiveSheet.Range("A1").Value = " Company-00" & I
            ActiveSheet.PrintOut
        Next
        ActiveSheet.Range("A1").ClearContents
        Application.ScreenUpdating = xScreen
    End If
End Sub

3. Then press F5 key to run this code, and a prompt box is popped out to remind you enter the number of copies that you want to print the current worksheet, see screenshot:

doc increment when printting 1

4. Click OK button, and your current worksheet is printing now, and at the same time, the printed worksheets are numbered Company-001, Company-002, Company-003…in cell A1 as you need.

Note: In the above code, the cell A1 will be inserted the sequence numbers that you ordered, and the original cell value in A1 will be cleared. And “Company-00” is the sequence number, you can change them to your need.


Excel Productivity Tools

Ribbon of Excel (with Kutools for Excel installed)

300+ Advanced Features Increase Your Productivity by 70%, and Help You To Stand Out From Crowd!

Would you like to complete your daily work quickly and perfectly? Kutools For Excel brings 300+ cool and powerful advanced features (Combine workbooks, sum by color, split cell contents, convert date, and so on...) for 1500+ work scenarios, helps you solve 80% Excel problems.

  •  Deal with all complicated tasks in seconds, help to enhance your work ability, get success from the fierce competition, and never worry about being fired.
  •  Save a lot of work time, leave much time for you to love and care the family and enjoy a comfortable life now.
  •  Reduce thousands of keyboard and mouse clicks every day, relieve your tired eyes and hands, and give you a healthy body.
  •  Become an Excel expert in 3 minutes, and get admiring glance from your colleagues or friends.
  •  No longer need to remember any painful formulas and VBA codes, have a relaxing and pleasant mind, give you a thrill you've never had before.
  •  Spend only $39, but worth than $4000 training of others. Being used by 110,000 elites and 300+ well-known companies.
  •  60-day unlimited free trial. 60-day money back guarantee. Free upgrade and support for 2 years. Buy once, use forever.
  •  Change the way you work now, and give you a better life immediately!

Office Tab Brings Efficient And Handy Tabs to Office (include Excel), Just Like Chrome, Firefox, And New IE

  • Increases your productivity by 50% when viewing and editing multiple documents.
  • Reduce hundreds of mouse clicks for you every day, say goodbye to mouse hand.
  • Open and create documents in new tabs of same window, rather than in new windows.
  • Help you work faster and easily stand out from the crowd! One second to switch between dozens of open documents!
Say something here...
symbols left.
You are guest ( Sign Up? )
or post as a guest, but your post won't be published automatically.
Loading comment... The comment will be refreshed after 00:00.
  • To post as a guest, your comment is unpublished.
    unknown · 1 months ago
    hey i want to change number of K11 cell number after print to 1-2-3-4-5-6 etc pls can u help ? and also tell me how to call that function pls help
  • To post as a guest, your comment is unpublished.
    Ib Alsa · 2 months ago
    Is there a way to select what values I want to print? for example I printed sequence 1 to 30 but need to reprint sequence 15 to 19 again.
  • To post as a guest, your comment is unpublished.
    Bill Turek · 3 months ago
    Works good for printing incremental #'s. How do I print every 5th,10, when needed?
  • To post as a guest, your comment is unpublished.
    Arash · 5 months ago
    Thanks a million
  • To post as a guest, your comment is unpublished.
    jennifer · 5 months ago
    My cell is I3 and the number is 2298 when I try the (VBA code: Auto increment cell value after each printing:) it gives me 22981 how do I get it to 2298,2299,2300
    • To post as a guest, your comment is unpublished.
      tan chee ho · 4 months ago
      thank you very much, it works for me. And i manage to make a few minor change to suit my needs. Really Appreciate to your sharing.
    • To post as a guest, your comment is unpublished.
      skyyang · 5 months ago
      Hi, jennifer,
      To deal with your problem, please apply the following VBA code:
      Note: Please change the prefix text and number to your own.

      Sub IncrementPrint_Num()
      Dim xCount As Variant
      Dim xScreen As Boolean
      Dim I As Long
      Dim xStr As String
      Dim xInt As Integer
      On Error Resume Next
      xStr = "Company-" 'prefix text
      xInt = 2291 'number
      LInput:
      xCount = Application.InputBox("Please enter the number of copies you want to print:", "Kutools for Excel")
      If TypeName(xCount) = "Boolean" Then Exit Sub
      If (xCount = "") Or (Not IsNumeric(xCount)) Or (xCount < 1) Then
      MsgBox "error entered, please enter again", vbInformation, "Kutools for Excel"
      GoTo LInput
      Else
      xScreen = Application.ScreenUpdating
      Application.ScreenUpdating = False
      For I = 1 To xCount
      xInt = xInt + 1
      ActiveSheet.Range("A1").Value = xStr & xInt
      ActiveSheet.PrintOut
      Next
      ActiveSheet.Range("A1").ClearContents
      Application.ScreenUpdating = xScreen
      End If
      End Sub

      Please try it, hope it can help you!
      • To post as a guest, your comment is unpublished.
        Richard · 3 months ago
        Hello can you help me with this? I want the xINT to be more than 5 digits. Everytime i put a number with 6 digits, the count goes back to 1. How can i prevent that?