ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   Using today formula for a template (https://www.excelbanter.com/excel-discussion-misc-queries/39216-using-today-formula-template.html)

Mike Busch

Using today formula for a template
 
I would like to use the =today() formula on a telplate, and have it work for
the first time it is used only. Is there a way. OK to make it clear, if I
have this in a template, I would like to open a telplate, have today's dat
appear. and when it is saved, I need that date in there perminantly. Thanks
in advance.

Duke Carey

You'll need to do that when you open the template copy.

If the target cell is empty then put today's date in it:

Private Sub Workbook_Open()

With Worksheets("Sheet1").Range("A1")
If .Text = "" Then
.Value = Date
End If
End With

End Sub


"Mike Busch" wrote:

I would like to use the =today() formula on a telplate, and have it work for
the first time it is used only. Is there a way. OK to make it clear, if I
have this in a template, I would like to open a telplate, have today's dat
appear. and when it is saved, I need that date in there perminantly. Thanks
in advance.


Mike Busch

So you are saying that I can not use the =today() formula for the date. If I
did it would keep changing, everytime it was opened.

"Duke Carey" wrote:

You'll need to do that when you open the template copy.

If the target cell is empty then put today's date in it:

Private Sub Workbook_Open()

With Worksheets("Sheet1").Range("A1")
If .Text = "" Then
.Value = Date
End If
End With

End Sub


"Mike Busch" wrote:

I would like to use the =today() formula on a telplate, and have it work for
the first time it is used only. Is there a way. OK to make it clear, if I
have this in a template, I would like to open a telplate, have today's dat
appear. and when it is saved, I need that date in there perminantly. Thanks
in advance.


Duke Carey

That is correct. But it's not a big deal to add the code that runs when you
open a workbook.

Press Alt-F11.
Press Ctrl-R
Find your template in the list, and under the template double-click on This
Workbook
Paste in the code below, changing Sheet1 to the name of the sheet where you
want the date and changing A1 to the address of the cell where you want the
date.

Save the file



"Mike Busch" wrote:

So you are saying that I can not use the =today() formula for the date. If I
did it would keep changing, everytime it was opened.

"Duke Carey" wrote:

You'll need to do that when you open the template copy.

If the target cell is empty then put today's date in it:

Private Sub Workbook_Open()

With Worksheets("Sheet1").Range("A1")
If .Text = "" Then
.Value = Date
End If
End With

End Sub


"Mike Busch" wrote:

I would like to use the =today() formula on a telplate, and have it work for
the first time it is used only. Is there a way. OK to make it clear, if I
have this in a template, I would like to open a telplate, have today's dat
appear. and when it is saved, I need that date in there perminantly. Thanks
in advance.



All times are GMT +1. The time now is 07:05 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com