Find last modified time stamp for a cell.

Tejas Kore

Board Regular
Joined
Nov 2, 2017
Messages
72
Office Version
  1. 365
Platform
  1. Windows
Hi Friends,

I wanted to know how can we get last modified time for a cell besides that cell using excel formula.

For eg: If you have some data in cell A1 ... You make changes to this cell A1 and I want to get the time at which this change was made in cell B1 using excel formulas.
 

Excel Facts

Which Excel functions can ignore hidden rows?
The SUBTOTAL and AGGREGATE functions ignore hidden rows. AGGREGATE can also exclude error cells and more.
You would have to use VBA to capture the date/time a cell was updated and store that in a cell somewhere.
A common methodology known as "date stamping" is using VBA to record when a specific cell us updated and write that to a particular cell.

Here is what that code would look like. Whenever cell A1 is manually updated by itself, this will update the date/time in cell B1.
To put this code in the proper place, right-click on the sheet tab name at the bottom of the screen, select View Code, and paste this code in the VB Editor window:
Code:
Private Sub Worksheet_Change(ByVal Target As Range)

'   Only run if one cell is updated
    If Target.Count > 1 Then Exit Sub
    
'   Run if cell A1 is updated
    If Target.Address = "$A$1" Then
'       add date/time stamp to cell B1
        Target.Offset(0, 1) = Now()
    End If
    
End Sub
 
Upvote 0
Hi Joe,

Thanks for your reply... I got it and it is working perfectly fine.
I had one more question what changes needs to be done in order to apply for a range instead of a cell ?
 
Upvote 0
I had one more question what changes needs to be done in order to apply for a range instead of a cell ?
Like this:
Code:
Private Sub Worksheet_Change(ByVal Target As Range)

    Dim rng As Range
    Dim isect As Range
    Dim cell As Range

'   Set range to apply to
    Set rng = Range("A:A")
    
'   See if updated cell(s) fall in range
    Set isect = Intersect(rng, Target)
    
'   Exit if updated cell not in our range
    If isect Is Nothing Then Exit Sub
    
'   Update time/date stamps
    For Each cell In isect
        cell.Offset(0, 1) = Now()
    Next cell
    
End Sub
 
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,182
Members
453,021
Latest member
Mohamed Magdi Tawfiq Emam

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