Automatically enter a "date modified" in a cell

guerreroca

New Member
Joined
Jul 14, 2010
Messages
3
I'm trying to find a way to get a "modified date" or "saved date" automatically entered into a cell in a worksheet, but I can't figure this out. I've seen numerous websites give VB code to do this, but I must be doing something wrong because a date never appears in the cell I select. I'm using Excel 2007. Can someone please show me step by step how to do this?

I need it to look like: Cell B2 says "Updated" and the date is actually in cell B3, so it would look like "Updated 07-14-2010". Thank you.
 

Excel Facts

How to create a cell-sized chart?
Tiny charts, called Sparklines, were added to Excel 2010. Look for Sparklines on the Insert tab.
Hi and welcome to the board!!!
There are several ways to do this. Do you really need it in a cell? Or would the footer work? You can also use one cell (B2) for both updated and the date?? Think about these options!! For your example, find the ThisWorkBook module in the VBE(ALT+F11) and paste this code
Code:
Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean)
Cancel = True
If Me.Saved = False Then Sheet1.Range("$B$4") = Date
    Application.EnableEvents = False
    Me.Save
    Application.EnableEvents = True
End Sub

lenze
 
Upvote 0
Hi Lenze,

I don't understand this. Am I supposed to change something in this code? I put this in VBE and saved it, then changed a cell, saved the workbook, even closed and reopened it, but no date shows up in any of the 4 worksheets in this workbook. I did change the ("$B$4") to ("$C$2") because that is the cell I want the date to show up in. (Not B2 as I originally said).

Thank you for your help!
 
Upvote 0

Forum statistics

Threads
1,216,102
Messages
6,128,852
Members
449,471
Latest member
lachbee

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top