HeRoseInThree
Board Regular
- Joined
- Jan 11, 2018
- Messages
- 103
Every couple of days I add data to column A. After I do, I insert another column A. I would like to see, if at any time, i have duplicate data in 3 consecutive columns.
Private Sub Worksheet_Change(ByVal Target As Range)
' Exit sub if multiple cells updated at once
If Target.CountLarge > 1 Then Exit Sub
' Exit sub if update is not in 1st column
If Target.Column > 1 Then Exit Sub
' Check to see if entry is equal to values in new two columns in same row
If (Target <> "") And (Target = Target.Offset(0, 1)) And (Target = Target.Offset(0, 2)) Then
' Highlight all three cells
Range(Target, Target.Offset(0, 2)).Interior.Color = 65535
End If
End Sub
I do not see any duplicate data across 3 consecutive columns in your example.
Note that this code does NOT run against existing data. It runs as new data is being entered into column A, and then compares the entry to the values in columns B and C in the same row.
There is a 2 in each column.
Thank you for you efforts and I apologize for not being more clear.I misunderstood. When you said "3 consecutive columns", to me that means the same row.
But it appears that is not the case.
That certainly complicates things a bit. I will need to amend my code some.