Numbering excel invoice form

  • Thread starter Thread starter norpro1
  • Start date Start date
N

norpro1

How do I set the excel invoice to automatically input the
next number each time the invoice template is opened?
I.E. Invoice # 1000
filled out, saved, printed and then closed.
Reopen invoice form now shows Invoice # 1001.
And so on for each use.

Thanks,
Norpro1
 
Hi
one way (using the Windows registry for storing the last number). Put
the following code in the workbook module (not in a standard module) of
your template:
- It changes cell A1 of the first sheet
- you may change the key identifiert according to your needs (e.g.
DEFAULTSTART, MYLOCATION, etc.)

Private Sub Workbook_Open()
Const DEFAULTSTART As Integer = 1
Const MYAPPLICATION As String = "Excel"
Const MYSECTION As String = "myInvoice"
Const MYKEY As String = "myInvoiceKey"
Const MYLOCATION As String = "A1"
Dim regValue As Long

With ThisWorkbook.Sheets(1).Range(MYLOCATION)
If .Text <> "" Then Exit Sub
regValue = GetSetting(MYAPPLICATION, MYSECTION, _
MYKEY, DEFAULTSTART)
.Value = CStr(regValue)
SaveSetting MYAPPLICATION, MYSECTION, MYKEY, regValue + 1
End With
End Sub
 
Frank,

Sounds like you can help me, but what you wrote went
flying right over my head. So, please dumb it down for me,
step by step where do I go and what do I do....

Thanks!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top