Tom's Guide | Tom's Hardware | Tom's Games
![]() |
![]() |
![]() |
I'm creating an invoice template but want the invoice number to change every time I open the template. Does anyone know how can I formulate a cell on the spreadsheet so that each time I open the workbook the number in that cell counts up? Thanks

You will probably need a piece of VBA code to accomplish this.
Try:
Private Sub Workbook_Open()
Range("a1").Value = Range("a1").Value + 1
End SubAssuming your Invoice number is in cell A1

Many thanks Mike. I'm afraid I only have very basic Excel knowledge and I don't understand what you mean. Please would you mind explaining (for dummies style!)
Thank you

My VBA skills are not that much greater than yours, I’m just beginning to delve into it.
To get the code to work you will need to first access the VBA editor:
Press ALT-F11Once it opens, on the Task Bar, press the Project Explorer button or press CTRL-R
When the Project Explorer window opens, find the line that reads VBAProject followed by your filename and Double Click on the line.
Next, at the bottom of the list that just appeared should be a line that reads “ThisWorkbook”
Double Click it and in the window that appears on the right, paste the code I gave you:Private Sub Workbook_Open()
Range("a1").Value = Range("a1").Value + 1
End SubPress ALT-F11 again to get out of the VBA editor and then save the file.
This should work……..

![]() |
QuickBooks File Transfer
|
Can I convert a xls file ...
|

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.
| Ads by Google |