Posted to microsoft.public.excel.programming
|
|
Auto increment a cell
Take a look at this:
http://www.anthony-vba.kefra.com/vba...ur_First_Macro
Regards,
Ryan---
--
RyGuy
"Jeff Johnson" wrote:
"Arod" wrote in message
...
The things is that I'm not familiar with the codes on VBE so i don't know
what to put. Also, I want the invoice number to increment automatically
when
I save the file.
With the workbook active, open the VB Editor (Alt+F11). You should see a
tree view with a node that says something like "VBAProject (<workbook
name)". Find the ThisWorkbook node below it and double-click it. A code
editor will appear.
You should see two dropdowns above the code editor. Drop down the left one.
Click the Workbook item. Now, in the right dropdown, select BeforeSave.
Enter the following code between Private... and End Sub lines (on its own
line):
Worksheets("<name of sheet containing your number").Range("<address of the
cell you want to update").Value = Worksheets("<same worksheet
name").Range("<same address").Value + 1
Save the workbook.
Please note that if the workbook has not been saved before (or the user
chooses Save As), this value will get incremented EVEN IF the user cancels
the Save dialog.
|