Forum Discussion

Deleted's avatar
Deleted
Mar 02, 2018

Data refresh timestamp (need help)

Hello,

I have a code below which basically identifies the changes within the V column and then timestamps it. When you change it manually it works like a charm. However = it is linked to an external data source (CRM) and when the DATA -> Refresh All -> refreshing the excel to get the latest data from he source it overwrites the timestamps, because the data is being refreshed and new rows might be generated so automatically the timestamps puts it to now and all of them changes. But when you change any values manually it will put the current time of the change within column V and that particular row.

Please help, thank you for your time.

Private Sub Worksheet_Change(ByVal Target As Range)
'Update 20140722
Dim WorkRng As Range
Dim Rng As Range
Dim xOffsetColumn As Integer
Set WorkRng = Intersect(Application.ActiveSheet.Range("V:V"), Target)
xOffsetColumn = 35
If Not WorkRng Is Nothing Then
Application.EnableEvents = False
For Each Rng In WorkRng
If Not VBA.IsEmpty(Rng.Value) Then
Rng.Offset(0, xOffsetColumn).Value = Now
Rng.Offset(0, xOffsetColumn).NumberFormat = "dd-mm-yyyy, hh:mm:ss"
Else
Rng.Offset(0, xOffsetColumn).ClearContents
End If
Next
Application.EnableEvents = True
End If
End Sub

No Replies

Resources