Show duplicate values for combination and it's reverse version

mrugesh

Board Regular
Joined
Aug 23, 2010
Messages
67
I have 4 digit numbers in two columns. What I need to see is if the combination of them is being repeated below. So, if the number in column A is 1000 & column B is 1300, combination of them will be 10001300. Now I need to see if this combination or it's other reverse version (13001000) is repeating below or not.
Can someone please help me here?
 

Excel Facts

Copy a format multiple times
Select a formatted range. Double-click the Format Painter (left side of Home tab). You can paste formatting multiple times. Esc to stop
You have those two numbers in the same row? And you need to see if that row is repeated in the exact or reverse order?
I want to be clear on your meaning.
 
Last edited:
Upvote 0
You have those two numbers in the same row? And you need to see if that row is repeated in the exact or reverse order?
I want to be clear on your meaning.

Correct. Those two numbers are in same row and I want to see if the combination is repeated in exact or reverse order.
 
Upvote 0
Would this Conditional Fomatting method suffice?
Select A2:B?? and apply the CF formula shown (adjust the ranges in the formula to match yours)

Excel Workbook
AB
1
212345698
310001300
490002568
513001000
658003030
765982222
865982222
911116548
1010001300
Repeat Pairs
Cells with Conditional Formatting
CellConditionCell FormatStop If True
A21. / Formula is =SUMPRODUCT(($A$2:$A$10&$B$2:$B$10=$A2&$B2)+($A$2:$A$10&$B$2:$B$10=$B2&$A2))/IF($A2=$B2,2,1)>1Abc
 
Last edited:
Upvote 0
Would this Conditional Fomatting method suffice?
Select A2:B?? and apply the CF formula shown (adjust the ranges in the formula to match yours)

Repeat Pairs

AB

<colgroup><col style="width: 30px; font-weight: bold;"><col style="width: 56px;"><col style="width: 56px;"></colgroup><tbody>
[TD="bgcolor: [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=CACACA]#CACACA[/URL] , align: center"]1[/TD]

[TD="bgcolor: [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=CACACA]#CACACA[/URL] , align: center"]2[/TD]
[TD="align: right"]1234[/TD]
[TD="align: right"]5698[/TD]

[TD="bgcolor: [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=CACACA]#CACACA[/URL] , align: center"]3[/TD]
[TD="bgcolor: [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=FFC000]#FFC000[/URL] , align: right"]1000[/TD]
[TD="bgcolor: [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=FFC000]#FFC000[/URL] , align: right"]1300[/TD]

[TD="bgcolor: [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=CACACA]#CACACA[/URL] , align: center"]4[/TD]
[TD="align: right"]9000[/TD]
[TD="align: right"]2568[/TD]

[TD="bgcolor: [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=CACACA]#CACACA[/URL] , align: center"]5[/TD]
[TD="bgcolor: [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=FFC000]#FFC000[/URL] , align: right"]1300[/TD]
[TD="bgcolor: [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=FFC000]#FFC000[/URL] , align: right"]1000[/TD]

[TD="bgcolor: [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=CACACA]#CACACA[/URL] , align: center"]6[/TD]
[TD="align: right"]5800[/TD]
[TD="align: right"]3030[/TD]

[TD="bgcolor: [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=CACACA]#CACACA[/URL] , align: center"]7[/TD]
[TD="bgcolor: [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=FFC000]#FFC000[/URL] , align: right"]6598[/TD]
[TD="bgcolor: [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=FFC000]#FFC000[/URL] , align: right"]2222[/TD]

[TD="bgcolor: [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=CACACA]#CACACA[/URL] , align: center"]8[/TD]
[TD="bgcolor: [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=FFC000]#FFC000[/URL] , align: right"]6598[/TD]
[TD="bgcolor: [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=FFC000]#FFC000[/URL] , align: right"]2222[/TD]

[TD="bgcolor: [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=CACACA]#CACACA[/URL] , align: center"]9[/TD]
[TD="align: right"]1111[/TD]
[TD="align: right"]6548[/TD]

[TD="bgcolor: [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=CACACA]#CACACA[/URL] , align: center"]10[/TD]
[TD="bgcolor: [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=FFC000]#FFC000[/URL] , align: right"]1000[/TD]
[TD="bgcolor: [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=FFC000]#FFC000[/URL] , align: right"]1300[/TD]

</tbody>

Conditional formatting
CellNr.: / ConditionFormat
A21. / Formula is =SUMPRODUCT(($A$2:$A$10&$B$2:$B$10=$A2&$B2)+($A$2:$A$10&$B$2:$B$10=$B2&$A2))/IF($A2=$B2,2,1)>1

<tbody>
[TD="bgcolor: [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=FFC000]#FFC000[/URL] "]Abc

<tbody>

</tbody>
[/TD]

</tbody>


Excel tables to the web >> Excel Jeanie HTML 4

Thank You so much, Peter! This works. You just saved me hours of manual work. :)
 
Upvote 0
I see you already have this solved but I wanted to try and contribute a VBA solution. Have a good one :)
Code:
Sub code()
Dim ColA As Variant, ColBrow As Variant
Dim rg As Range
Set rg = Range("A1").CurrentRegion
For i = 1 To rg.Rows.Count
    
    ColA = Range("A" & i)
    If Not Range("B1", "B" & rg.Rows.Count).Find(ColA) Is Nothing Then
        ColBrow = Range("B1", "B" & rg.Rows.Count).Find(ColA).Row
        If Range("B" & i) = Range("A" & ColBrow) Then
            Range("A" & i).EntireRow.Interior.Color = RGB(180, 230, 180)
            Range("A" & ColBrow).EntireRow.Interior.Color = RGB(180, 230, 180)
        End If
    End If
    ColB = 0
Next i
End Sub
 
Upvote 0
I see you already have this solved but I wanted to try and contribute a VBA solution. Have a good one :)
Code:
Sub code()
Dim ColA As Variant, ColBrow As Variant
Dim rg As Range
Set rg = Range("A1").CurrentRegion
For i = 1 To rg.Rows.Count
    
    ColA = Range("A" & i)
    If Not Range("B1", "B" & rg.Rows.Count).Find(ColA) Is Nothing Then
        ColBrow = Range("B1", "B" & rg.Rows.Count).Find(ColA).Row
        If Range("B" & i) = Range("A" & ColBrow) Then
            Range("A" & i).EntireRow.Interior.Color = RGB(180, 230, 180)
            Range("A" & ColBrow).EntireRow.Interior.Color = RGB(180, 230, 180)
        End If
    End If
    ColB = 0
Next i
End Sub

Thanks for this one. I will try this one as well. Always better to have more than one bullet in your gun. :)
 
Upvote 0
I see you already have this solved but I wanted to try and contribute a VBA solution. Have a good one :)
Hi sugoimm
I noticed with your code and my sample data, that
- it did not colour rows 7 & 8 even though they are repeats.
- if I added a new row with the values 5656 and 5656 in the 2 columns, it did colour that row even though the row is not duplicated.
 
Upvote 0
I will try this one as well. Always better to have more than one bullet in your gun. :)
So, if you are interested in a macro alternative, you could try this one which I believe overcomes the issues with the previous code that I mentioned in post 9. I have assumed the actual data starts in row 2.
Code:
Sub CheckRepeats()
  Dim d As Object
  Dim a As Variant
  Dim r As Long
  
  Set d = CreateObject("Scripting.Dictionary")
  a = Range("A1", Range("B" & Rows.Count).End(xlUp)).Value
  For r = 2 To UBound(a)
    a(r, 1) = IIf(a(r, 1) < a(r, 2), a(r, 1) & a(r, 2), a(r, 2) & a(r, 1))
    d(a(r, 1)) = d(a(r, 1)) + 1
  Next r
  Application.ScreenUpdating = False
  For r = 2 To UBound(a)
    If d(a(r, 1)) > 1 Then Rows(r).Resize(, 2).Interior.ColorIndex = 45
  Next r
  Application.ScreenUpdating = True
End Sub
 
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,181
Members
453,022
Latest member
Mohamed Magdi Tawfiq Emam

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