Last Modified Cell VBA

Braaterz

New Member
Joined
Feb 5, 2015
Messages
7
I found this code in a prior thread that is working but hoping someone can help modify for 2 issues.

1. If I highlight a row or range that contains row R, it places the =NOW() result in every column 4 to the right of each active cell. Is there a way to make sure it only does it related to the referenced column (R in this case)?

2. The code runs if you click to activate the cell, any way to make it only when the contents are actually modified?


Code:
Private Sub Worksheet_SelectionChange(ByVal Target As Range)

   If Intersect(Target, Range("R4:R1000")) Is Nothing Then Exit Sub
    Target.Offset(0, 4) = Now()

End Sub

Thanks
 
Last edited:

Excel Facts

Convert text numbers to real numbers
Select a column containing text numbers. Press Alt+D E F to quickly convert text to numbers. Faster than "Convert to Number"
If you are just looking for a date/time stamp to record when a value in column R was last updated, it just needs to be in a Worksheet_Change event procedure, not Worksheet_SelectionChange.

Try this:
Code:
Private Sub Worksheet_Change(ByVal Target As Range)

    Dim rng As Range
    Dim cell As Range
    
    Set rng = Intersect(Target, Range("R:R"))
    
    If rng Is Nothing Then Exit Sub
    
    For Each cell In rng
        cell.Offset(0, 4) = Now()
    Next cell
        
End Sub
 
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,175
Members
453,021
Latest member
Justyna P

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