DATE AND TIME

F

FRANKIE

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.
 
J

J.E. McGimpsey

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.
 

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