# automatic increment invoice number in excel



## afgewill (Oct 15, 2004)

I've designed an invoce in Excel. I'd like to have it automatically increment the invoice number each time I open it.

Right now I open it, increment the number by one, save it, then put the original number back in. It works, but is a pain.


Is there some way (macro, VBA, formula) that would do this for me?

I'm not worried about saving the invoice I'm working on, I print it and close without saving the changes.

TIA

Will


----------



## XL Guru (Aug 30, 2003)

>> Is there some way (macro, VBA, formula) that would do this for me?

Formula, no ; VBA, yes.

Rightclick the Excel icon left of "File" in the menu bar, select "View Code".

Paste this into the workbook module:

Private Sub Workbook_Open()
Range("A1") = Range("A1") + 1
ActiveWorkbook.Save
End Sub

, then change "A1" (both refs) to the cell where you want the number.

Close the VBE, save & close the file.

Open & close it a few times to test (don't forget to clear the range then save the *last* time you test).

Rgds,
Andy


----------



## afgewill (Oct 15, 2004)

Works beautifully, exactly what I needed. Thanks


----------



## Zack Barresse (Jul 25, 2004)

Hello,

Just as a side note, there was some good discussion on this matter here ...

http://www.vbaexpress.com/forum/showthread.php?t=324&highlight=increment


----------

