Look at Damon's code in Archive2. (NT)
Im looking for something a bit different
This works when the sheet is calculated, but I want it to appear as soon as the sheet opens. I thought a workbook_open() would be good, but when i use this, everytime from then on, when i open a file to view it, dont make changes, and close, excel asks me if i want to save. I want to prevent this message from coming up, while at the same time putting the date in "a1" without having to put in anyother data. any ideas?
Private Sub Workbook_Open()
If Sheet1.[A1] = "" Then Sheet1.[A1] = Now
End Sub
Will this do ?
Ivan
Rob
Try this code in the Workbook_Open event. Do not put anything in Sheet1.A1 as the code looks for it to be empty.
If it is empty (first time workbook is opened), it inserts the current date and saves the file with its current name. You may then do whatever and save it with another name if you wish.
When you set up the file, format A1 (or whichever cell you are using) to display the date in the required format.
Open code will run each time, but will make no further changes.
Private Sub Workbook_Open()
With Worksheets("Sheet1")
If .Cells(1, 1) = "" Then
.Cells(1, 1).Formula = Now
ActiveWorkbook.Save
Else
End If
End With
End Sub
Any help?
Regards
Robb
Re: Im looking for something a bit different
the only problem with that is, like i said, this is a template. So...if i open it, a temp file, "file1.xls" opens until i save it. I dont want this to save until i have given it a name. I tried putting activeworkbook.save in the open, but then it caused problems when the template was opened a second time. Ivans code seems to work well...thanks for the input though!