View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.programming
[email protected] john.opie@gmail.com is offline
external usenet poster
 
Posts: 7
Default Creating non-volatile Date


Nigel wrote:
Hi All
I have a requirement to, from within VBA, store the
current date into a worksheet.cell. But for that date to
be non-volatile.

If I use the system date functions then this will always
change, after the worksheet is reloaded. What is the best
approach to overcome this?

Cheers
Nigel


Hi -

This puts the both the data and the time in cell A1:

ThisWorkbook.Sheets("NameOfSheet").Cells(A1).Value = Now()

where you replace "NameOfSheet" with the worksheet name that you
actually are using. Also adjust the Cells(A1) to the proper cell
reference that you need.

By using the attribute ".Value" of the function "Now()" in ".Cells(A1)"
of the worksheet "ThisWorkbook.Sheets("NameOfSheet")" you get the
nonvolatile results of the function "Now()". It's a great way of
timestamping any and all workbooks and worksheets...

Hope this helps

John