Hi everyone,
I am doing a sales funnel, where I have a dropdown list of stages in column G, and any changes are reflected in column H in the form of a time stamp.
The problem I have is whenever someone clicks on the individual cell but did not make any changes (e.g. click on a cell titled "prospect", but choose "prospect" from the list), the date would automatically update itself.
View attachment 41442
How do I amend the following code so that there will only be a change in date if the value in the cell changes (e.g. from prospect to qualify)? Any advice?
Private Sub Worksheet_Change(ByVal Target As Range)
Dim WorkRng As Range
Dim Rng As Range
Dim xOffsetColumn As Integer
Set WorkRng = Intersect(Application.ActiveSheet.Range("G:G"), Target)
xOffsetColumn = 1
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
I am doing a sales funnel, where I have a dropdown list of stages in column G, and any changes are reflected in column H in the form of a time stamp.
The problem I have is whenever someone clicks on the individual cell but did not make any changes (e.g. click on a cell titled "prospect", but choose "prospect" from the list), the date would automatically update itself.
View attachment 41442
How do I amend the following code so that there will only be a change in date if the value in the cell changes (e.g. from prospect to qualify)? Any advice?
Private Sub Worksheet_Change(ByVal Target As Range)
Dim WorkRng As Range
Dim Rng As Range
Dim xOffsetColumn As Integer
Set WorkRng = Intersect(Application.ActiveSheet.Range("G:G"), Target)
xOffsetColumn = 1
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