Inserting Automatic Date

  • Thread starter Johnathon Aaron Steel
  • Start date
J

Johnathon Aaron Steel

I have a Template and when I open it up I want it to be able to insert
the date in a specific cell on open and not have to type it in.

Is this possible?

Thanx

JAS
 
P

Paul B

Johnathon, put this in the cell

=TODAY()
--
Paul B
Always backup your data before trying something new
Please post any response to the newsgroups so others can benefit from it
Feedback on answers is always appreciated!
Using Excel 2002 & 2003
 
D

David McRitchie

Hi Johnathon,

Current Date:
If you are just using the file during day and not over midnight
you can use =TODAY() which will change after midnight and
a recalculation takes place.

Date First Opened
Do you want a constant set permanently when the workbook is
originally opened using an Event macro. If the sheet is deleted
a new one will be created next time workbook is opened.

In your Template, right click on the logo to left of the menu bar,
View code, insert the following code after your Option Explicit
which you should already have.

Sub WorkBook_Open()
On Error Resume Next
If Len(Worksheets("newdoc").Name) = 0 Then
On Error GoTo 0
Sheets.Add After:=Sheets(Sheets.Count) '-- place at end
ActiveSheet.Name = "newdoc"
Range("A1") = Now() '-- or for just date use DATE
Columns("A:A").EntireColumn.AutoFit
Sheets(1).Activate
Else
On Error GoTo 0
End If
End Sub
 
B

Bob Phillips

Private Sub Workbook_Open()
Worksheets("Sheet1").Range("A1").Value = Format(Date, "dd mmm yyyy")
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
 
Top