Forum Discussion

AJ-FLAME's avatar
AJ-FLAME
Copper Contributor
Aug 12, 2022

Automatically inserting a sequential invoice number

Hello everyone, Currently I pay a company to print blank invoices with sequential numbers. I am attempting to find a way to print a similar blank invoice (that I have created in excel) but on each ...
  • HansVogelaar's avatar
    HansVogelaar
    Aug 12, 2022

    AJ-FLAME 

    The code that I posted will only run when you open the workbook.

    As an alternative, remove the Workbook_Open code.

    Then select Insert > Module in the Visual Basic Editor.

    Copy the following code into the module:

    Sub PrintInvoices()
        Dim i As Long
        Dim n As Long
        n = Val(InputBox("How many copies do you want to print?"))
        For i = 1 To n
            With Worksheets("Sheet1").Range("D1")
                .Value = .Value + 1
            End With
            Worksheets("Sheet1").PrintOut
        End With
    End Sub

    Running this macro will prompt you for the number of invoices to be printed. The invoice number will be incremented each time.

    If you wish, you can assign the macro to a button on the sheet, or to a Quick Access Toolbar, or to a keyboard shortcut.

Resources