# Solved: Excel 2003 - add worksheet date last modified to a cell



## snorkytheweasel (May 3, 2006)

In cell A2 I want to display the date that the worksheet was last modified. 

Is there a function that does this? 

Or is this a job for VBA? If so , how do I do this (from scratch)?

TIA, TTFN


----------



## bomb #21 (Jul 1, 2005)

I guess by modified you mean "changed and saved", since a file that's modified but closed without saving isn't techinically modified. (?)

Try the code below in the Workbook module (which you should be able to get at by rightclicking the Excel icon left of "File" in the menu bar and choosing "View Code" from the pop-up).

Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean)
Sheets("Sheet1").Range("A2") = Date
End Sub


----------



## snorkytheweasel (May 3, 2006)

That worked - Thanks!

I was unable to modify the date format when using Format -> Cells -> Date.

It's not the end of the world, but it begs the question: am I doing something wrong?


----------



## bomb #21 (Jul 1, 2005)

You can modify by entering the cell (F2), then pressing Enter to exit.

But to be honest, I don't know -- I'll look it up.


----------



## Zack Barresse (Jul 25, 2004)

```
Sheets("Sheet1").Range("A2") = Format(Date, "mm-dd-yy")
```
HTH


----------

