Extract Unique Values from a Range of cells

mcrossler

New Member
Joined
May 31, 2018
Messages
9
I've seen formulas that can extract unique values from a row or column, like
{=IFERROR(INDEX($B$3:$B$15, MATCH(0,COUNTIF($D$2:D2, $B$3:$B$15), 0)),"")}
but I can't make this work for a range of cells, like this:

ABCDEFGHIJKLMN
1BobAliceDavid
2MarkAliceNancy
3GeorgeSandyKarenAliceBobDavidGeorgeKarenMarkNancySandy
4KarenNancyBob
5

<tbody>
</tbody>
Where the data in A1:C4 is extracted to show only unique values of G3:N3.

Ideally, I'd also like to have the results sorted, too.

I won't be supporting this spreadsheet, so I would prefer not to use VBA to do this.

Thanks!
 
Perfect for now! Sorting was an added bonus.

Eric,

Sorting the values was where I encountered problems, because =IF(A1:D7<>"",COUNTIF(A1:D7,"<"&A1:D7),"") does not work with those values - all zeros (???). See gray area.

I got something with (blue area).
=IF(A1:D7<>"",COUNTIF(A1:D7,"<"&"'"&A1:D7),"")
But there are some strange results 1 in K1, 6 in K3 (???)

A
B
C
D
E
F
G
H
I
J
K
L
M
N
1
10/14​
0​
1​
2
4/6​
5/8​
0​
0​
17​
22​
3
2/3​
3/4​
4/6​
5/8​
0​
0​
0​
0​
6​
11​
17​
22
4
2/3​
3/4​
4/6​
5/8​
0​
0​
0​
0​
6​
11​
17​
22​
5
2/3​
3/4​
4/6​
5/8​
0​
0​
0​
0​
6​
11​
17​
22​
6
2/3​
3/4​
4/6​
5/8​
0​
0​
0​
0​
6​
11​
17​
22
7
2/3​
3/4​
4/6​
0​
0​
0​
6​
11​
17​
8

<tbody>
</tbody>


I have to leave now. I hope you find a solution

M.
 
Last edited:
Upvote 0

Excel Facts

Difference between two dates
Secret function! Use =DATEDIF(A2,B2,"Y")&" years"&=DATEDIF(A2,B2,"YM")&" months"&=DATEDIF(A2,B2,"MD")&" days"
Marcelo, I played around with several sorting formulas based on the classic COUNTIF("<") formula, and like you, couldn't quite get them to work. I keep thinking I'm just missing a piece somewhere. I'll keep playing around with it.

mcrossler, glad that works for you! If I figure out the sorting version, I'll let you know.
 
Upvote 0
Marcelo, I played around with several sorting formulas based on the classic COUNTIF("<") formula, and like you, couldn't quite get them to work. I keep thinking I'm just missing a piece somewhere. I'll keep playing around with it.

Yes, doesn't work with such fractions as text - maybe we're missing something "obscure" ;)
With ordinary texts like names worked perfectly for me.


A
B
C
D
E
F
G
H
I
J
K
L
1
Bob​
2
Mark​
Alice​
3
George​
Sandy​
Mark​
Alice​
Bob​
George​
Mark​
Sandy​
4
George​
Sandy​
Mark​
Alice​
5
George​
Sandy​
Mark​
Alice​
6
George​
Sandy​
Mark​
Alice​
7
George​
Sandy​
Mark​

<tbody>
</tbody>


Array formula in G3 copied across
=IFERROR(INDIRECT(TEXT(SMALL(IF($A$1:$D$7<>"",IF(1+COUNTIF($A$1:$D$7,"<"&$A$1:$D$7)-SUM(COUNTIF($F3:F3,$A$1:$D$7))=1,ROW($A$1:$D$7)*10^5+COLUMN($A$1:$D$7))),1),"R0C00000"),0),"")
Ctrl+Shift+Enter

M.
 
Upvote 0
A possible solution using formulas


A
B
C
D
E
F
G
H
I
J
K
L
1
10/14​
2
4/6​
5/8​
3
2/3​
3/4​
4/6​
5/8​
10/14​
2/3​
3/4​
4/6​
5/8​
4
2/3​
3/4​
4/6​
5/8​
5
2/3​
3/4​
4/6​
5/8​
6
2/3​
3/4​
4/6​
5/8​
7
2/3​
3/4​
4/6​
8

Array formula in G3 copied across until you get a blank (gray area)
=IFERROR(INDIRECT(TEXT(SMALL(IF($A$1:$D$7<>"",IF(COUNTIF($A$1:$D$7,"<"&"'"&$A$1:$D$7)-COUNTIF($A$1:$D$7,$A$1:$D$7)+1-SUM(COUNTIF($F3:F3,$A$1:$D$7))=1,ROW($A$1:$D$7)*10^5+COLUMN($A$1:$D$7))),1),"R0C00000"),0),"")
Ctrl+Shift+Enter

M.
 
Upvote 0

Forum statistics

Threads
1,216,191
Messages
6,129,429
Members
449,509
Latest member
ajbooisen

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