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

Does the VLOOKUP table have to be sorted?
No! when you are using an exact match, the VLOOKUP table can be in any order. Best-selling items at the top is actually the best.

Joe4

MrExcel MVP, Junior Admin
Joined
Aug 1, 2002
Messages
60,139
Office Version
  1. 365
Platform
  1. Windows
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
 
Solution

Alimarie

New Member
Joined
Jan 18, 2021
Messages
2
Office Version
  1. 365
Platform
  1. Windows
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!
 

Joe4

MrExcel MVP, Junior Admin
Joined
Aug 1, 2002
Messages
60,139
Office Version
  1. 365
Platform
  1. Windows
You are welcome.
Glad I was able to help.
 

Forum statistics

Threads
1,148,280
Messages
5,745,826
Members
423,981
Latest member
ph1l

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
Top