Find rows with same ID but different value in another column

swapnilk

Board Regular
Joined
Apr 25, 2016
Messages
75
Office Version
  1. 365
  2. 2021
Platform
  1. Windows
Hi,

I have a table like this:

NameGroup
1A
2B
3B
5D
1A
10D
8F
2A

Result
NameGroup
2B
2A

I would like to select the Name that occurs more than once with different Group.

I am currently using Pivot Table to get the result by adding Name in "Rows" and Group in "Columns" and "Values" and then i manually go through the list to find Name with multiple different Groups.

Can someone please suggest a way to achieve the same result as above, it can be formula, VBA or anything that will make the work faster. Since, now after using Pivot Table i have to manually go through the list to find Name with different Groups, sometimes the data is around 300000 rows.
 

Excel Facts

How to total the visible cells?
From the first blank cell below a filtered data set, press Alt+=. Instead of SUM, you will get SUBTOTAL(9,)
Can you confirm what version you have? Assuming you don't have 365 maybe this - VBA maybe a better solution as I'm not how this solution will fair with 300000 rows...

You will need to drag this down far enough to return rows count greater than True in H2;

Find rows with same ID but different value in another column_swapnilk.xlsx
ABCDEFGH
1NameGroupCOUNTconcatextractUniqueTRUE
21A11A1AFALSE2
32B12B2BTRUE
43B 3B1AFALSE
55D 5D2ATRUE
61A11A1FALSE
710D 10D1FALSE
88F 8F1FALSE
92A12A1FALSE
10
11Result
12NameGroup
132B
142A
Sheet1
Cell Formulas
RangeFormula
C2:C9C2=IF(COUNTIF([Name],[@Name])=2,1,0)
D2:D9D2=[@Name]&[@Group]
F2:F9F2=IF(ROWS($F$2:F2)>COUNTIF(Table1[COUNT],1),1,INDEX(Table1[concat],SMALL(IF(Table1[COUNT]=1,ROW(Table1[Name])-ROW(Table1[[#Headers],[Name]])),ROWS($F$2:F2))))
G2:G9G2=COUNTIF($F$2:$F$9,F2)=1
H2H2=COUNTIF(Unique,TRUE)
A13:A14A13=IFNA(INDEX(Table1[Name],MATCH(IF(ROWS(A$13:A13)>$H$2,"",INDEX(extract,SMALL(IF(Unique=TRUE,ROW(extract)-ROW($F$1)),ROWS(A$13:A13)))),Table1[concat],0)),"")
B13:B14B13=IFNA(INDEX(Table1[Group],MATCH(IF(ROWS(A$13:A13)>$H$2,"",INDEX(extract,SMALL(IF(Unique=TRUE,ROW(extract)-ROW($F$1)),ROWS(A$13:A13)))),Table1[concat],0)),"")
Press CTRL+SHIFT+ENTER to enter array formulas.
Named Ranges
NameRefers ToCells
extract=Sheet1!$F$2:INDEX(Sheet1!$F$2:$F$300000,COUNTA(Sheet1!$F$2:$F$300000))F2:G9, A13:B14
Unique=Sheet1!$G$2:INDEX(Sheet1!$G$2:$G$300000,COUNTA(Sheet1!$G$2:$G$300000))H2, A13:B14
 
Last edited:
Upvote 0
Can you confirm what version you have? Assuming you don't have 365 maybe this - VBA maybe a better solution as I'm not how this solution will fair with 300000 rows...

You will need to drag this down far enough to return rows count greater than True in H2;
Thank you for the reply. I have access to 365.

I found an alternate way. Use
Excel Formula:
=TRANSPOSE(FILTER(A:A, B2=B:B))
to get all Group Names and then use
Excel Formula:
=IF(COUNTA(C2:I2)-COUNTIF(C2:I2,LOOKUP(2,1/(C2:I2<>""),C2:I2))=0,"OK","DIFF")
to get Names with different Groups, then use filter to show only DIFF.
 
Upvote 0
I have access to 365.

I suggest that you update your Account details (or click your user name at the top right of the forum) so helpers always know what Excel version(s) & platform(s) you are using as the best solution often varies by version. (Don’t forget to scroll down & ‘Save’)

1646029593892.png
 
Upvote 0

Forum statistics

Threads
1,214,954
Messages
6,122,461
Members
449,085
Latest member
ExcelError

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