AUTO NUMBERING

W

WYN

hi all,i have made an invoice template for my work.how can i get these
invoices to sequentially number each time i use the invoice and save as iun
the customers name?any suggestions will be greatly appreciated. thanks wyn.
 
F

Frank Kabel

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
 
W

WYN

hi frank,thanks for the info.as i am still fairly new to all this i just have
a few questions.
(1) i am not sure what about the window registry.
(2) workbook module __ standard module
(3)i enterd the code in vba but i get expected end window and the word if
highlighted!!
any suggestions?
thx wyn
 
Top