ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   Date Function (https://www.excelbanter.com/excel-discussion-misc-queries/61348-date-function.html)

Khangura

Date Function
 
I was wondering if we could set DATE & TIME on a worksheet (in a cell), which
would default to the present time. Once the work is complete and the
worksheet is saved, the DATE & TIME should be saved as well.

On review at a later time, the DATE & TIME should reflect the date and time
the worksheet was saved, and not the present time.

Any help would be greatly appreciated. THX.



Bob Phillips

Date Function
 
One way

Option Explicit

Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As
Boolean)
Worksheets("Sheet1").Range("A1").Value = _
Format(Now, "dd mmm yyyy hh:mm:ss")
End Sub

'This is workbook event code.
'To input this code, right click on the Excel icon on the worksheet
'(or next to the File menu if you maximise your workbooks),
'select View Code from the menu, and paste the code


--
HTH

Bob Phillips

(remove nothere from email address if mailing direct)

"Khangura" wrote in message
...
I was wondering if we could set DATE & TIME on a worksheet (in a cell),

which
would default to the present time. Once the work is complete and the
worksheet is saved, the DATE & TIME should be saved as well.

On review at a later time, the DATE & TIME should reflect the date and

time
the worksheet was saved, and not the present time.

Any help would be greatly appreciated. THX.






All times are GMT +1. The time now is 02:46 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com