VBA row last updated help

Alimarie

New Member
Joined
Jan 18, 2021
Messages
2
Office Version
  1. 365
Platform
  1. Windows
Hi all,

Wondering if you can help me with some VBA code.

I would like to identify the date when a row was last updated.
I'd like this date to be recorded in column B.
Data is recorded in columns C to AI.

Could someone please help me out with what to post in VBA? I'm going round in circles.

Thanks!!
 

Excel Facts

Format cells as time
Select range and press Ctrl+Shift+2 to format cells as time. (Shift 2 is the @ sign).
Welcome to the Board!

The following code will write a Date/Time stamp to column B with any cell in columns C:A1 is manually updated.
Just right-click on the worksheet name at the bottom of your worksheet, select View Code, and paste this VBA code in the VB Editor window:
VBA Code:
Private Sub Worksheet_Change(ByVal Target As Range)

    Dim rng As Range
    Dim cell As Range
    
'   Find if cell updated in our "watched" range
    Set rng = Intersect(Target, Columns("C:AI"))

'   Exit if no cells updated
    If rng Is Nothing Then Exit Sub
    
    Application.EnableEvents = False
    Application.ScreenUpdating = False
    
'   Loop through all cells just updated
    For Each cell In rng
        Cells(cell.Row, "B") = Now()
    Next cell
    
    Application.ScreenUpdating = True
    Application.EnableEvents = True

End Sub
 
Upvote 0
Solution
This w
Welcome to the Board!

The following code will write a Date/Time stamp to column B with any cell in columns C:A1 is manually updated.
Just right-click on the worksheet name at the bottom of your worksheet, select View Code, and paste this VBA code in the VB Editor window:
VBA Code:
Private Sub Worksheet_Change(ByVal Target As Range)

    Dim rng As Range
    Dim cell As Range
   
'   Find if cell updated in our "watched" range
    Set rng = Intersect(Target, Columns("C:AI"))

'   Exit if no cells updated
    If rng Is Nothing Then Exit Sub
   
    Application.EnableEvents = False
    Application.ScreenUpdating = False
   
'   Loop through all cells just updated
    For Each cell In rng
        Cells(cell.Row, "B") = Now()
    Next cell
   
    Application.ScreenUpdating = True
    Application.EnableEvents = True

End Sub
This worked perfectly. Thank you so much!
 
Upvote 0
You are welcome.
Glad I was able to help.
 
Upvote 0

Forum statistics

Threads
1,214,985
Messages
6,122,606
Members
449,089
Latest member
Motoracer88

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