Current Date

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi, I am really lost
I have to have a date that has to give me the current date by opening the first time
And then after by opening the same sheet stay unchanged
for security reason it can't be put in by the user himself
So I need it to be saved on the template

Thanks for helpin
Hugo
 
Hi Hugo
try something like the following: Put the code in your workbook module
(not in a standard module):

Private Sub Workbook_Open()
dim wks as worksheet
dim rng as range
set wks = worksheets("Sheet1")
set rng = wks.range("A1")

if rng.value <>"" then
rng.value = date
rng.numberformat = "MM/DD/YYYY"
end if

End Sub
 
Add this formula to the template

Sub Auto_Open()

Worksheets("Sheet1").Range("A1").Value = Date

End Sub


--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)
 
Back
Top