View Single Post
  #11   Report Post  
Posted to microsoft.public.excel.programming
phale phale is offline
external usenet poster
 
Posts: 8
Default Auto increment a cell

Yes I did copy and paste--and when I got the syntax error, I tried making
changes like taking the s off the worksheets, etc.
I know so little about this I just assumed the file name should be
referenced. Am in the process of reading the VBE help file and taking the
tutorial you recommended.

So. . .would this code be correct?

Thanks for your help!

Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As
Boolean)
Worksheets("Sheet1").Range("G2").Value=Worksheets( "Sheet1").Range("G2
").Value + 1


"Jeff Johnson" wrote:

"phale" wrote in message
...
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").Va lue=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?


Is that your EXACT code (i.e., did you copy and paste)? Because if so, the
first "Worksheets" is missing the "s" at the end.

Also, you appear to be trying to use the name of the WORKBOOK (i.e., the
file name) as an argument to the Worksheets() function instead of the name
of the SHEET as I told you. The workbook itself will already be open; you
don't need to reference it.