Current Date

H

Hugo

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
 
F

Frank Kabel

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
 
B

Bob Phillips

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)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top