Remove duplicates (including original) based on a conditional?

scootsy

New Member
Joined
Mar 23, 2018
Messages
1
I need to find and remove all instances of duplicate values including the original, if any of the duplicates are status 1. I can't just find and delete all status 1 entries, because any names repeated that are at status 2 would need to be deleted as well. Would it be easier to search all status 1's, take the relative reference name and delete all instances of that? or is there a simpler way?

For example:

Column A Column B
StatusName
2A
2B
1B
2C
2C
1D
2D

<tbody>
</tbody>

Should become:

StatusName
2A
2C
2C

<tbody>
</tbody>
 

Excel Facts

Formula for Yesterday
Name Manager, New Name. Yesterday =TODAY()-1. OK. Then, use =YESTERDAY in any cell. Tomorrow could be =TODAY()+1.
Welcome to the Board!

You can do this with a couple of array formulas:

ABCDE
1StatusNameStatusName
22A2A
32B2C
41B2C
52C
62C
71D
82D

<colgroup><col style="width: 25pxpx"><col><col><col><col><col></colgroup><thead>
</thead><tbody>
</tbody>
Sheet10

Array Formulas
CellFormula
D2{=IFERROR(INDEX($A$2:$A$8,SMALL(IF(COUNTIFS($A$2:$A$8,1,$B$2:$B$8,$B$2:$B$8)=0,ROW($B$2:$B$8)-ROW($B$2)+1),ROWS($D$2:$D2))),"")}
E2{=IFERROR(INDEX($B$2:$B$8,SMALL(IF(COUNTIFS($A$2:$A$8,1,$B$2:$B$8,$B$2:$B$8)=0,ROW($B$2:$B$8)-ROW($B$2)+1),ROWS($D$2:$D2))),"")}

<thead>
</thead><tbody>
</tbody>
Entered with Ctrl+Shift+Enter. If entered correctly, Excel will surround with curly braces {}.
Note: Do not try and enter the {} manually yourself

<tbody>
</tbody>



Depending on your layout and size of data, a macro might be worth considering too.
 
Upvote 0
Welcome to the MrExcel board!

Your requirement is not clear to me. If the very first status value in your sample data was 1 instead of 2, would that first row appear in the required result or not?
I ask because Eric's formula would remove that row but to me it isn't a duplicate so shouldn't be removed.

If my interpretation above is correct, then perhaps you could consider this manual method.
1. Formula in C2 is copied down.
2. Use AutoFilter to filter column C for TRUE values.
3. When filtered, delete all the rows below the header.
4. Delete column C entirely

Excel Workbook
ABC
1StatusNameCheck
22AFALSE
32BTRUE
41BTRUE
52CFALSE
62CFALSE
71DTRUE
82DTRUE
Delete Dupes
 
Upvote 0
I think the point Peter makes is sensible...

Row\Col
A​
B​
C​
D​
E​
F​
1​
StatusName
3​
2​
1
AIdxStatusName
3​
2
B
1​
1​
A
4​
1
B
4​
2​
C
5​
2
C
5​
2​
C
6​
2
C
7​
1
D
8​
2
D

In D1 control+shift+enter, not just enter:

=SUM(IF(ISNA(MATCH(B2:B8,IF(COUNTIFS(B2:B8,IF(A2:A8=1,B2:B8))>1,B2:B8),0)),1))

In D3 control+shift+enter, not just enter, and copy down:

=IF(ROWS($D$3:D3)>$D$1,"",SMALL(IF(ISNA(MATCH($B$2:$B$8,IF(COUNTIFS($B$2:$B$8,IF($A$2:$A$8=1,$B$2:$B$8))>1,$B$2:$B$8),0)),ROW($A$2:$A$8)-ROW($A$2)+1),ROWS($D$3:D3)))

In E3 just enter, copy across to F3, and down:

=IF($D3="","",INDEX(A$2:A$8,$D3))
 
Upvote 0

Forum statistics

Threads
1,214,648
Messages
6,120,726
Members
448,987
Latest member
marion_davis

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