Make a list with criteria and no duplicates

Stuepef

Board Regular
Joined
Oct 23, 2017
Messages
128
Office Version
  1. 2021
Platform
  1. Windows
I receive a spreadsheet with the information listed below. The spreadsheet has a list of employees, spouse, children with DOB's and packages (Medical & Dental). I want to create a formula that extracts every employee with the relationship 1 without duplicates. My current formula extracts employees with the 1 relationship, but duplicates due to some employees having both medical AND dental packages. I am looking for help on re configuring the following formula to list every employee with relationship 1 without duplicates:

Code:
=IFERROR(INDEX($A$2:$A$20,AGGREGATE(15,6,ROW($2:$20)/($E$2:$E$20=1),ROW(1:1))),"")

[TABLE="class: grid, width: 500"]
<tbody>[TR]
[TD]Family Group[/TD]
[TD]Employee Name[/TD]
[TD]# of People[/TD]
[TD]DOB[/TD]
[TD]Relationship[/TD]
[TD]Package[/TD]
[/TR]
[TR]
[TD]Bobby Jackson[/TD]
[TD]Bobby Jackson[/TD]
[TD]4[/TD]
[TD]01/04/1975[/TD]
[TD]1[/TD]
[TD]MEDICAL[/TD]
[/TR]
[TR]
[TD]Bobby Jackson[/TD]
[TD]Sandra Jackson[/TD]
[TD]4[/TD]
[TD]8/23/1973[/TD]
[TD]2[/TD]
[TD]MEDICAL[/TD]
[/TR]
[TR]
[TD]Bobby Jackson[/TD]
[TD]Collette Jackson[/TD]
[TD]4[/TD]
[TD]5/12/2004[/TD]
[TD]3[/TD]
[TD]MEDICAL[/TD]
[/TR]
[TR]
[TD]Bobby Jackson[/TD]
[TD]Joe Jackson[/TD]
[TD]4[/TD]
[TD]6/7/2008[/TD]
[TD]3[/TD]
[TD]MEDICAL[/TD]
[/TR]
[TR]
[TD]Bill O'Brian[/TD]
[TD]Bill O'Brian[/TD]
[TD]2[/TD]
[TD]4/12/1969[/TD]
[TD]1[/TD]
[TD]MEDICAL[/TD]
[/TR]
[TR]
[TD]Bill O'Brian[/TD]
[TD]Jackie O'Brian[/TD]
[TD]2[/TD]
[TD]9/4/1971[/TD]
[TD]2[/TD]
[TD]MEDICAL[/TD]
[/TR]
[TR]
[TD]Matt James[/TD]
[TD]Matt James[/TD]
[TD]3[/TD]
[TD]7/10/1987[/TD]
[TD]1[/TD]
[TD]MEDICAL[/TD]
[/TR]
[TR]
[TD]Matt James[/TD]
[TD]Beckie James[/TD]
[TD]3[/TD]
[TD]4/11/1990[/TD]
[TD]2[/TD]
[TD]MEDICAL[/TD]
[/TR]
[TR]
[TD]Matt James[/TD]
[TD]Richard James[/TD]
[TD]3[/TD]
[TD]12/5/2010[/TD]
[TD]3[/TD]
[TD]MEDICAL[/TD]
[/TR]
[TR]
[TD]Bobby Jackson[/TD]
[TD]Bobby Jackson[/TD]
[TD]4[/TD]
[TD]1/4/1975[/TD]
[TD]1[/TD]
[TD]DENTAL[/TD]
[/TR]
[TR]
[TD]Bobby Jackson[/TD]
[TD]Sandra Jackson[/TD]
[TD]4[/TD]
[TD]8/23/1973[/TD]
[TD]2[/TD]
[TD]DENTAL[/TD]
[/TR]
[TR]
[TD]Bobby Jackson[/TD]
[TD]Collette Jackson[/TD]
[TD]4[/TD]
[TD]5/12/2004[/TD]
[TD]3[/TD]
[TD]DENTAL[/TD]
[/TR]
[TR]
[TD]Bobby Jackson[/TD]
[TD]Joe Jackson[/TD]
[TD]4[/TD]
[TD]6/7/2008[/TD]
[TD]3[/TD]
[TD]DENTAL[/TD]
[/TR]
[TR]
[TD]George Wilks[/TD]
[TD]George Wilks[/TD]
[TD]2[/TD]
[TD]4/12/1969[/TD]
[TD]1[/TD]
[TD]DENTAL[/TD]
[/TR]
[TR]
[TD]George Wilks[/TD]
[TD]Jackie Wilks[/TD]
[TD]2[/TD]
[TD]9/4/1971[/TD]
[TD]2[/TD]
[TD]DENTAL[/TD]
[/TR]
[TR]
[TD]Matt James[/TD]
[TD]Matt James[/TD]
[TD]3[/TD]
[TD]7/10/1987[/TD]
[TD]1[/TD]
[TD]DENTAL[/TD]
[/TR]
[TR]
[TD]Matt James[/TD]
[TD]Beckie James[/TD]
[TD]3[/TD]
[TD]4/11/1990[/TD]
[TD]2[/TD]
[TD]DENTAL[/TD]
[/TR]
[TR]
[TD]Matt James[/TD]
[TD]Richard James[/TD]
[TD]3[/TD]
[TD]12/5/2010[/TD]
[TD]3[/TD]
[TD]DENTAL[/TD]
[/TR]
[TR]
[TD]Amy Belts[/TD]
[TD]Amy Belts[/TD]
[TD]1[/TD]
[TD]12/30/1954[/TD]
[TD]1[/TD]
[TD]DENTAL[/TD]
[/TR]
</tbody>[/TABLE]


Here is what I am attempting to do with the formula:
[TABLE="class: grid, width: 500"]
<tbody>[TR]
[TD]Employee Name[/TD]
[/TR]
[TR]
[TD]Bobby Jackson[/TD]
[/TR]
[TR]
[TD]Bill O'Brian[/TD]
[/TR]
[TR]
[TD]Matt James[/TD]
[/TR]
[TR]
[TD]George Wilks[/TD]
[/TR]
[TR]
[TD]Amy Belts[/TD]
[/TR]
</tbody>[/TABLE]

thank you for your help!
 
Last edited:

Excel Facts

When did Power Query debut in Excel?
Although it was an add-in in Excel 2010 & Excel 2013, Power Query became a part of Excel in 2016, in Data, Get & Transform Data.
Here is some VBA code that will do what you are looking for. It's outputting your results to columns J. You can change that to suite your needs.

Code:
Sub UniqueOnes()
Dim AR()
AR = Range("A2:F" & Range("A" & Rows.Count).End(xlUp).Row).Value


With CreateObject("Scripting.Dictionary")
    For i = 1 To UBound(AR)
        If AR(i, 5) = 1 And Not .exists(AR(i, 2)) Then .Add AR(i, 2), i
    Next i
    Range("J1").Resize(UBound(.keys) + 1, 1).Value = Application.Transpose(.keys)
End With


End Sub
 
Last edited:
Upvote 0
Thats weird, this works, didnt think it would

=IFERROR(INDEX($B$2:$B$20,SMALL(IF(($E$2:$E$20=1),ROW($A$2:$A$20)),ROW(A1))-(ROW(A$2)-1),1),"")
Array formula, use Ctrl-Shift-Enter


Amy doesnt appear on your list using your formula

This also works

=IFERROR(INDEX(A$2:A$20,AGGREGATE(15,6,ROW(A$2:A$20)/(E$2:E$20=1),ROWS(A$2:A2))-(2-1),1),"")
 
Last edited:
Upvote 0
I have tried both of your formulas and they create duplicates like this:

Bobby Jackson
Bill O'Brian
Matt James
Bobby Jackson
George Wilks
Matt James
Amy Belts

I tried a few different formulas, do you see any issue with this:
Code:
{=IFERROR(INDEX($A$2:$A$20,MATCH(0,COUNTIF($L$2:L2,$A$2:$A$20),0)),"")}
 
Upvote 0
I have tried both of your formulas and they create duplicates like this:

Bobby Jackson
Bill O'Brian
Matt James
Bobby Jackson
George Wilks
Matt James
Amy Belts

I tried a few different formulas, do you see any issue with this:
Code:
{=IFERROR(INDEX($A$2:$A$20,MATCH(0,COUNTIF($L$2:L2,$A$2:$A$20),0)),"")}

Yep, my formulas were rubbish, I see the duplicates now.
Still thinking..
 
Upvote 0
Try:
This is an array formula that must be entered with CTRL-SHIFT-ENTER.
Drag down as needed.
Excel Workbook
ABCDEF
1Family GroupEmployee Name# of PeopleDOBRelationshipPackage
2Bobby JacksonBobby Jackson41/4/19751MEDICAL
3Bobby JacksonSandra Jackson48/23/19732MEDICAL
4Bobby JacksonCollette Jackson45/12/20043MEDICAL
5Bobby JacksonJoe Jackson46/7/20083MEDICAL
6Bill O'BrianBill O'Brian24/12/19691MEDICAL
7Bill O'BrianJackie O'Brian29/4/19712MEDICAL
8Matt JamesMatt James37/10/19871MEDICAL
9Matt JamesBeckie James34/11/19902MEDICAL
10Matt JamesRichard James312/5/20103MEDICAL
11Bobby JacksonBobby Jackson41/4/19751DENTAL
12Bobby JacksonSandra Jackson48/23/19732DENTAL
13Bobby JacksonCollette Jackson45/12/20043DENTAL
14Bobby JacksonJoe Jackson46/7/20083DENTAL
15George WilksGeorge Wilks24/12/19691DENTAL
16George WilksJackie Wilks29/4/19712DENTAL
17Matt JamesMatt James37/10/19871DENTAL
18Matt JamesBeckie James34/11/19902DENTAL
19Matt JamesRichard James312/5/20103DENTAL
20Amy BeltsAmy Belts112/30/19541DENTAL
21
22Employee Name
23Bobby Jackson
24Bill O'Brian
25Matt James
26George Wilks
27Amy Belts
Sheet
 
Upvote 0

Forum statistics

Threads
1,223,885
Messages
6,175,183
Members
452,615
Latest member
bogeys2birdies

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