Rolling duplicate columns

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.
 

Excel Facts

VLOOKUP to Left?
Use =VLOOKUP(A2,CHOOSE({1,2},$Z$1:$Z$99,$Y$1:$Y$99),2,False) to lookup Y values to left of Z values.
How is data added to column A?
Manually entered one cell at a time, or the whole columns data copied and pasted in?

And what do you want to happen if there are 3 consecutive columns with duplicate data?
Do you want them highlighted? Or do you want some type of pop-up message?
 
Upvote 0
The data is entered in manually, a few cells at most.
If 3 consecutive columns are duplicates, highlight the 3 cells that match. I never had a pop-up message, tho... Whichever is easier.
 
Upvote 0
Right-click on the Sheet tab name at the bottom of the screen, select View Code, and paste this code in the VB Editor window that opens up:
VBA Code:
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 think this should do what you want.
 
Upvote 0
Copy and pasted. Tested, no results.
1586365434896.png

1586365459490.png
 
Upvote 0
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.
 
Upvote 0
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.
 
Upvote 0
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.
 
Upvote 0
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.
Thank you for you efforts and I apologize for not being more clear.
 
Upvote 0

Forum statistics

Threads
1,224,818
Messages
6,181,151
Members
453,021
Latest member
Justyna P

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
Back
Top