Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

incremental number when workbook opened 1

Status
Not open for further replies.

ajking

Technical User
Aug 13, 2002
229
Is it possible to set up a number that programmatically increments each time a workbook is opened?TIA
 
If the number is in a cell you can put this code in the workbooks on open event.

Private Sub Workbook_Open()
Range("a1") = Range("a1") + 1
End Sub

Just change "a1" with whatever cell is storing your number.

HTH,
Eric
 
Thanks for replying.
The scenario I have is there is a workbook template which users will pull in and do their work. they are then forced to SaveAs..
This means the original template isn't saved thus when it opens it will appear to be the first. So I reckon what I am asking is their a way of keeping a record of each time the template is opened even though the template isn't saved?
TIA
 
You might try this...
Code:
Private Sub Workbook_Open()
Range("a1") = Range("a1") + 1
Application.DisplayAlerts = False
With ActiveWorkbook
  .SaveAs .Path & "\" & "Tempname.xlt"
End With 
End Sub
Use whatever file name your is

VOLA! :)

Skip,
Skip@TheOfficeExperts.com
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top