View Single Post
  #9   Report Post  
Posted to microsoft.public.excel.programming
Gord Dibben Gord Dibben is offline
external usenet poster
 
Posts: 22,906
Default Invoice Numbering

Which set of code are you using?

If Ivan's code see below for his notes

.................................................. ..............

To display the number in a cell in the worksheet, you can either add a
line of code that sets it when the file is created, " Range("A1") =
InvNo " for example, or add the following code to a module in the
template:

Function Invoice()
Invoice = Int(Mid(ThisWorkbook.BuiltinDocumentProperties("Ti tle"),9))
End Function

Then you can simply put the formula " =Invoice() " anywhere in the
file and it will contain the correct number and never be out of sync
with the file.

................................................

You would use C5 in either case.


Gord

On Sat, 29 Mar 2008 10:31:22 -0700 (PDT), wrote:

Thanks everyone. Everything seems to be working except for showing the
invoice number in cell C5. Any thoughts on how to do this would be
great. thanks.

On Mar 29, 1:22*pm, Gord Dibben <gorddibbATshawDOTca wrote:
Dave Peterson posted this a while back.

If the workbook has never been saved, which is the case with a newly created
workbook from the Template, the invoice number will increment.

After saving, the number will not increment when opening that saved workbook.

Private Sub Workbook_Open()
* * if thisworkbook.path = "" then
* * * * 'it's never been saved, so increment
* * * * Sheet1.Range("H16").Value = Sheet1.Range("H16").Value + 1
* * end if
End Sub

Incorporate into your macro.

Gord Dibben *MS Excel MVP



On Sat, 29 Mar 2008 06:16:11 -0700 (PDT), wrote:
Thanks Nigel. One question - when i go to reopen a previously created
invoice it runs the macro again and duplicates the invoice with a new
number. is there any way to prevent this? Thanks.- Hide quoted text -


- Show quoted text -