Invoice Numbers - Please Help!

G

Guest

This is all new to me so please be patient! lol

What I'm trying to do is to have automatic advancing invoice numbers in my
template. I'm using Excel 2003. This is what I've tried and just can't get
it to work. Any help would be appreciated. Thank you.

Private Sub Workbook_Open()
Const DEFAULTSTART As Integer = 1000
Const MYAPPLICATION As String = "Excel"
Const MYSECTION As String = "Wardinvoice2"
Const MYKEY As String = "Wardinvoice2Key"
Const MYLOCATION As String = "E5"
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
 
J

JE McGimpsey

What does "can't get it to work" mean?

The code appears to be fine if stored in a template file with E5 blank.
Workbooks created from that template will have increasing serial numbers.
 
G

Guest

E5 is blank in the template file, but it won't advance past 1000. Any ideas
what I might have done wrong?
 
J

JE McGimpsey

Not really. It works fine for me in both MacXL and XL03.

It sounds like the SaveSetting is not writing to the registry for some
reason.
 

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

Top