I tried following your directions and typed in the following code:
Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean)
Worksheet("Receivingtemplate2.xlt").Range("G2").Value=Worksheets("Receiving
template.xlt").Range("G2
").Value + 1
Private Sub Workbook_Open()
End Sub
And I am getting a syntax error. Can you tell from this what I am doing
wrong?
Thanks!
"Jeff Johnson" wrote:
> "Arod" <(E-Mail Removed)> wrote in message
> news
FE77103-28D0-4A34-88FD-(E-Mail Removed)...
>
> > 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.
>
>
>