DATE AND TIME

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

Guest

I want to put a function in a template that will automatically display the current date. But once the sheet is closed and reopened not display the current date, display the date the sheet was originally created.
 
One way:

Put this event macro in the ThisWorkbook code module of the template
(right-click on the workbook title bar and choose View Code):

Private Sub Workbook_Open()
With Sheets("Sheet1").Range("A1")
If IsEmpty(.Value) Then
.NumberFormat = "dd mmm yyyy"
.Value = Date
End If
End With
End Sub

Change "Sheet1", "A1" and the date format to suit.
 
Back
Top