Auto Numbering

C

chew

I'm trying to set-up an invoice using thr Sales invoice template on excel, is there any way that, every time you open the invoice worksheet that it auotmatically count's up 1
 
C

Charlie

Below is a post I found by Frank Kabel. It might be just
what you need:
****
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


--
Regards
Frank Kabel
Frankfurt, Germany
-----Original Message-----
I'm trying to set-up an invoice using thr Sales invoice
template on excel, is there any way that, every time you
open the invoice worksheet that it auotmatically count's
up 1
 
Top