excelvba

How do I track date since specific cells in a row has been changed?


How do I track date since specific cells in a row has been changed? and keep todays date refreshed and updated. (for a full column of rows, so each row with a change in it is updated next to that row)

so say I want to track changes to cell B C F G L when those cells in a row have been modified. it updates to say AC showing the last updated date when cells were changed. and not simply clicked into but data actually updated and changed.

so if data is changed in B2, or F2, or L2 etc the date is updated in AC2

I have like 0 vba knowledge beyond knowing how to input the code to use

Id like to automatically track and keep it automatically updated

and after searching a while I came across this but I dont know how to set it to a set of specific columns like only update if I change something within B C F G L columns

Private Sub Worksheet_Change(ByVal Target As Range)
    If Not Application.Intersect(Range("$D:$N"), Target) Is Nothing Then
       Range("G" & Target.Row).Value = Date
    End If
End Sub

additionally it updates even when I dont type in new information and simply click into the cell. In which I only want it to update when data is actually changed.

also I want the today function to stay up to date even when I dont click into a cell.

I figured out the part for calculating the time difference between the 2


Solution

  • You can define not contiguous ranges like this:

    Private Sub Worksheet_Change(ByVal Target As Range)
        If Not Application.Intersect(Range("B:B,C:C,F:F,G:G,L:L"), Target) Is Nothing Then
           Range("AC" & Target.Row).Value = Date
        End If
    End Sub