Date Formula

  • Thread starter Thread starter Ronnie
  • Start date Start date
R

Ronnie

Is there a way to have a date automatically inserted the first time a
document is opened and then not again?
 
Automatically......only by code.

Manually, first time opened, select a cell and CTRL + ;

Workbook_Open code that runs only if a cell is blank.

Private Sub Workbook_Open()
With Sheets("Sheet1").Range("A1")
If .Value = "" Then
..Value = Format(Now, "mm/dd/yyyy hh:mm:ss")
End If
End With
End Sub

Of course the workbook has to be opened at least once in order to add the code
to Thisworkbook module and saved.

Next time opened, date added to A1 but not on subsequent openings.


Gord Dibben MS Excel MVP
 

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

Back
Top