Last Modify Date

waterballoon

New Member
Joined
Jun 15, 2011
Messages
35
I am trying to have a cell in each of my tabs show the last date that each respective tab was modified...is this possible?

Thanks in advance...:)
 

Excel Facts

How to change case of text in Excel?
Use =UPPER() for upper case, =LOWER() for lower case, and =PROPER() for proper case. PROPER won't capitalize second c in Mccartney
Code:
[COLOR="Blue"]Private[/COLOR] [COLOR="Blue"]Sub[/COLOR] Worksheet_Change([COLOR="Blue"]ByVal[/COLOR] Target [COLOR="Blue"]As[/COLOR] Range)
    Cells(1, 1) = DateValue(Now)
[COLOR="Blue"]End[/COLOR] [COLOR="Blue"]Sub[/COLOR]
 
Upvote 0
There's better way. Place this module into ThisWorkbook module. Now there will day on all sheets in A1 cell:
Code:
Private Sub Workbook_SheetChange(ByVal Sh As Object, ByVal Target As Range)
    Application.EnableEvents = False
    Sh.Cells(1, 1) = DateValue(Now)
    Application.EnableEvents = True
End Sub
 
Last edited:
Upvote 0
Better add the lines as shown, to avoid problems.
Otherwise the code changes the same worksheet, which calls the code again, which changes the worksheet, which calls the code again, etcetera, you see where this is going...

Code:
Private Sub Workbook_SheetChange(ByVal Sh As Object, ByVal Target As Range)
    Application.EnableEvents = False
    Sh.Cells(1, 1) = DateValue(Now)
    Application.EnableEvents = True
End Sub
 
Upvote 0
The solutions provided will not detect modifications to the worksheets like formatting cells, embeeding objects etc...

Maybe a better approach is to check for the workbook Saved Property which changes whenever the workbook is modified including cell formatting etc..

In the workbook module :

Code:
Option Explicit

Private Sub Workbook_SheetSelectionChange(ByVal Sh As Object, ByVal Target As Range)
    Call UpdateCell(Sh)
End Sub

Private Sub Workbook_SheetDeactivate(ByVal Sh As Object)
    Call UpdateCell(Sh)
End Sub

Private Sub Workbook_BeforeClose(Cancel As Boolean)
    Call UpdateCell(ActiveSheet)
    Me.Saved = False
End Sub

Private Sub UpdateCell(ByVal Sh As Worksheet)

    If Not Me.Saved Then
        Application.EnableEvents = False
        Sh.Cells(1, 1) = DateValue(Now)
        Me.Saved = True
        Application.EnableEvents = True
    End If

End Sub
 
Upvote 0

Forum statistics

Threads
1,224,517
Messages
6,179,239
Members
452,898
Latest member
Capolavoro009

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