How do I save Date values in Excel-sheets????


Posted by Thomas Christiansson on March 10, 2001 4:43 AM

Hello Excel specialists.
Im pretty new at playing around with excel but I have a questione which I have asked people and searched the internet and still haven't found a solution for.
Maybe you know a "workaround".

I have made a very simple Invoice to a friend of mine.
To make it as simple as possible I have used the TODAY() command to get todays date when she start ups the template. This is all very easy and great, BUT(!).

When the invoice is saved and you bring it back up again 2 months later, the TODAY() brings up todays date and not the date two months ago, which I was hoping for.

Sooo, my question is. How can I "save" the date from when I first saved the invoice sheet????
I have figured out that TODAY() isnt such a good use for me, but what else can I use???

Anyone have a suggestion??? Someone more than me must have had this problem right????

I thank you all who have read this far.
Hopefully you have asolution for me..
Thanx..

Thomas



Posted by David Hawley on March 10, 2001 5:57 AM


Hi Thomas

You will need some simple VBA for this.

Right click on the sheet picture, top left next to "File" and select "View Code"

Paste this over the top of what you see:


Private Sub Workbook_Open()
If Not IsDate(Sheet1.Range("A1")) Then Sheet1.Range("A1") = Date
End Sub


Now the "Sheet1" bit is the code name for a Worksheet. You will see the code name for whatever sheet you want in the "Project Explorer" window to the left. It is the name NOT inside the brackets. It will always be the word "Sheet" follwed by a number.

To return to Excel Push Alt+Q. Now save your Template. Whenever it is opened the current date will be placed in cell A1, if there is not already a Date in it.


Dave
OzGrid Business Applications