Add date automatically

  • Thread starter Thread starter Bob Pearce - Australia
  • Start date Start date
B

Bob Pearce - Australia

When I open an Excel template worksheet, how can I get the date to
automatically update in a cell?
 
You could use a formula that changes to the current date -- no matter when it
opens:
=today()

If you want date that doesn't change after the first time it's applied, you
could use a macro:

Option Explicit
Sub auto_Open()
With ThisWorkbook.Worksheets("Sheet1").Range("a1")
If IsEmpty(.Value) Then
.Value = Date
End If
End With
End Sub

This looks to see if A1 on Sheet1 is empty. If it is, it plops in today's date.
 
Thanks Dave!
Dave Peterson said:
You could use a formula that changes to the current date -- no matter when
it
opens:
=today()

If you want date that doesn't change after the first time it's applied,
you
could use a macro:

Option Explicit
Sub auto_Open()
With ThisWorkbook.Worksheets("Sheet1").Range("a1")
If IsEmpty(.Value) Then
.Value = Date
End If
End With
End Sub

This looks to see if A1 on Sheet1 is empty. If it is, it plops in today's
date.
 
Back
Top