Create date

  • Thread starter Thread starter David
  • Start date Start date
D

David

Hello

I have a excel template that the user opens fills out and saves it by
giving it a filename. The problem I'm having is there is a a date field
that they need to enter in the date for that days information but they
are not filling it in. Is there a function I can put in that cell that
will put a date in it when the file is created?

The file is saved first thing in the morning and is filled out and saved
throughout the day until the next morning



TIA
David
 
How about this?

Function CreationDate() as String
CreationDate = ActiveWorkbook.BuiltinDocumentProperties("Creation
Date").Value
End Function

In A1 enter =CreationDate()


HTH,
JP
 
JP said:
How about this?

Function CreationDate() as String
CreationDate = ActiveWorkbook.BuiltinDocumentProperties("Creation
Date").Value
End Function

In A1 enter =CreationDate()


HTH,
JP
Can't seem to get it to work. Any other ideas
 
It worked on my machine.

1. Did you paste it into a standard module?
2. Did you fix the word wrapping? The Google text editor wraps the
function and might cause unintended errors.

You might have to "qualify" the reference, for example if I put the
function into my personal (hidden) workbook, I would call the function
by typing =PERSONAL.XLS!CreationDate()


HTH,
JP
 
That Function stored in a module in the Template will give you the creation date
of the Template only, not the workbook you just opened from the Template.

The opened workbook has no created date until it is saved.

To get a date for workbook just created you could place code in the Template
Thisworkbook module.

Note:you will have to open the Template itself to add the code, not just a
workbook opened from the Template.

Private Sub Workbook_Open()
If ActiveWorkbook.ActiveSheet.Range("A1") = "" Then
ActiveWorkbook.ActiveSheet.Range("A1").Value = Format(Date, "mmmm dd yyyy")
End If
End Sub

Note.....when you save the workbook the code will be saved with it, creating the
macro warning when the saved workbook is opened again.

It might be easier to train your users to hit CTRL + ; on a cell when they first
open the workbook.


Gord Dibben MS Excel MVP
 
Gord said:
That Function stored in a module in the Template will give you the creation date
of the Template only, not the workbook you just opened from the Template.

The opened workbook has no created date until it is saved.

To get a date for workbook just created you could place code in the Template
Thisworkbook module.

Note:you will have to open the Template itself to add the code, not just a
workbook opened from the Template.

Private Sub Workbook_Open()
If ActiveWorkbook.ActiveSheet.Range("A1") = "" Then
ActiveWorkbook.ActiveSheet.Range("A1").Value = Format(Date, "mmmm dd yyyy")
End If
End Sub

Note.....when you save the workbook the code will be saved with it, creating the
macro warning when the saved workbook is opened again.

It might be easier to train your users to hit CTRL + ; on a cell when they first
open the workbook.


Gord Dibben MS Excel MVP
Works Great now Thank you Both for your help
 
Back
Top