sequential invoice numbering

  • Thread starter Thread starter Scott Davidson
  • Start date Start date
S

Scott Davidson

How do I formulate a cell to add one to the previous invoice# each
time the "xxxx" invoice file is opened. Please and thank you
 
Scott

You could add code to the workbook_open event, thus (to add this open the
VBE (Alt+F11) and right click on the ThisWorkbook entry for the file name.
Paste the code in the resultant window, close the VBE and save the workbook.
(Change the references accordingly)

Private Sub Workbook_Open()
Worksheets("Sheet1").Range("A1").Value =
Worksheets("Sheet1").Range("A1").Value + 1
End Sub

--
HTH
Nick Hodge
Microsoft MVP - Excel
Southampton, England
(e-mail address removed)
 
Scott

You could add code to the workbook_open event, thus (to add this open the
VBE (Alt+F11) and right click on the ThisWorkbook entry for the file name.
Paste the code in the resultant window, close the VBE and save the workbook.
(Change the references accordingly)

Private Sub Workbook_Open()
Worksheets("Sheet1").Range("A1").Value =
Worksheets("Sheet1").Range("A1").Value + 1
End Sub


I think I did as shown exept changed "A1"s to "J5"s (the cell that I
would like to have the invoice # in). changed security to accept the
macro but get a syntax error with the value= line highlited
thanks again
Scott
 
Scott

Did you put the two main lines of code on one line? (Outlook Express breaks
the line of text at 50 characters or so).

--
HTH
Nick Hodge
Microsoft MVP - Excel
Southampton, England
(e-mail address removed)
 
The codes given by Nick works fine if you use it the first
time. But if you do intend to save the invoice and open it
later. The invoice no. will increase as well.

I'm not sure and I maybe wrong.
 
Rick

You are correct. As far as I remember the Op wanted to increment the number
each time the workbook was opened. That's what the code does.

--
HTH
Nick Hodge
Microsoft MVP - Excel
Southampton, England
(e-mail address removed)
 
Nick thanks a million or two ,putting the code on one line worked
perfectly. you are truly skilled
Thanks again for your time
Scott
 
Back
Top