Escolar Documentos
Profissional Documentos
Cultura Documentos
com
Dioptimalkan 1 jam yang lalu
Lihat yang asli Segarkan
Search... Go
Home Advanced Excel 3 Ways to extract unique values from a range in Excel
Scenario
Suppose you have a list of customer names. The list has some duplicate values. You wish to
extract unique values from it. Unique values would be a distinct list.
Sample File
Click on the link below and download the excel le for reference.
Solutions
1. Advanced Filter
Follow the steps shown below in the animation
STEPS
Go to Data tab in the menu
In Sort and Filter box, Click Advancedbutton
Choose"Copy to another location"
In "List range :" box, select a range from which unique values need to be extracted (including
header)
In "Copy to :" box, select a range in which nal output to be put
Check Unique records only
Click Ok
FORMULA
Copy the above formula and paste it into cell D3. And paste it down till the cell D12 (Select the
range D3:D12 and press Ctrl+D).
HOW TO USE
Follow the steps shown below in the animation
FORMULA
=IFERROR(INDEX($B$3:$B$15, MATCH(0,IF(ISBLANK($B$3:$B$15),1,COUNTIF($D$2:D2,
$B$3:$B$15)), 0)),"")
Copy the above formula and paste it into cell D3. And paste it down till the cell D12 (Ctrl+D).
HitCTRL+ SHIFT + ENTER to conrm this formula. If done correctly, Excel will automatically
place curly braces {...} around the formula.
After placing curly braces, the above formula would look like this :
{=IFERROR(INDEX($B$3:$B$15, MATCH(0,IF(ISBLANK($B$3:$B$15),1,COUNTIF($D$2:D2,
$B$3:$B$15)), 0)),"")}
VBA CODE
Option Explicit
Sub
CreateUniqueList()
HOW TO USE
Warning :If you want to keep your original data (not overwrite unique values), make a copy of it
(Paste original data to another range or tab) Otherwise original data would be removed.
Select range >> Go to Data option >> Click on Remove Duplicates >> Select the column
that contains duplicates >> Ok
Important Note :
If you have multiple columns in a range and you want to remove duplicates based on a single
column, make sure only the column that contains duplicates is selected.
Remove Duplicates by a column
2. If you want to remove duplicates based on all the columns (whole row), make sure all the
columns are selected.
Related Articles
1.Count Unique values in a column
2.Count Unique values in multiple columns
3.Select and Count Duplicate values in Excel
Thanks a lot
Reply
Andrey Metelskiy 11 February 2015 at 14:16
It works only for 1 column not for the 2d range
Reply
Replies
Reply
Reply
Reply
AB
11
1
22
2
1
1
33
3
2
1
3
Reply
Replies
=IF(COUNTIF(A$2:A2,A2)=1,A2,"")
Reply
=IFERROR(INDEX('Pocketbook Data'!$C$12:$C$31,MATCH(0,COUNTIF('Chart of
Accounts'!$B$4:B17,'Pocketbook Data'!$C$12:$C$31),0)),"")
Reply
Replies
Deepanshu Bhalla
Deepanshu Bhalla
i.e. My rst formula was in cell n2 and the example formula references d2 because the rst line is
blank.
Further confusing is that when you evaluate the formula using formula auditing it looks to work right up
to the last step when it switches from the correct value to zero.
HTH
Michael
Also thanks Deepanshu for taking the time to publish this information.
Reply
Thanks in advance!
Reply
Reply
=IFERROR(INDEX(PNRExport!$F$1:$F$800,MATCH(0,IF(ISBLANK(PNRExport!$F$1:$F$800),1,COUNTIF($F$5:
F24,PNRExport!$F$1:$F$800)),0)),"")
Reply
Now I have a situation where a list has blanks and duplicates, very similar to your example Version 2: IF
BLANK VALUES IN A LIST but heres the catch . . . for this effort, I have a requirement to keep the duplicates
for reporting purposes but remove the blanks. I might be over thinking this.
Here is the formula Ive used but of course it removes duplicates which I need to keep:
{=IFERROR(INDEX(WIP!$A$3:$A$501, MATCH(0,IF(ISBLANK(WIP!$A$3:$A$501),1,COUNTIF($A$2:A55,
WIP!$A$3:$A$501)), 0)),"")}
Reply
Reply
Reply
Reply
Reply
Anonymous 10 December 2015 at 18:00
Thanks for providing these tips!
I'm trying do this across 3 columns, but there are no results. If I restrict the range to just one column than it
works ne, but nothing for 3 columns.
Does this not work for multiple columns, and if not, is there any other alternative that does?
thanks!
Reply
Dave
Deepanshu
Jhonson
Neha
Sohan
...and not in the order that they occur in the column. I have a similar need with extracting values in ranked
order, but have an existing workaround.
Thanks again.
Reply
Reply
Reply
Reply
Stephane Beauls 3 March 2016 at 17:23
The vba gives me the rst and second as duplicate...
And the rst cell in the list has a name now Its called "Extract"
Any one has an idea why and how to x?
Reply
Reply
Fantastic Trick to get a dynamic list. I'm a bit confused on how to extend the list beyond 15 rows. I've
unsuccessfully changed all values from 15 to 40 rows, but it failed.
Reply
Replies
Changing references from $B$15 to $b$30 does not pick up addl rows beyond row 15
Deepanshu Bhalla
Make sure you are changing reference from $B$15 to $B$30 in all the three places in the formula.
Press CTRL SHIFT ENTER to conrm this formula rather than simple ENTER. If you do it correctly, you
would see the formula enclosed in curly brackets.
Marc Froemelt 5 May 2016 at 08:20
Thank you for your quick response and for pointing out my omission to you CTRL SHIFT ENTER - all is
well now
Deepanshu Bhalla
Reply
Hi there,
It works for me. But honestly I didn't get that formula. I would appreciate if someone helps me to understand.
Here is my understanding:
Index($E$2:$E$1000, Match(0,countif($A$3:A3,$E$2:$E$1000),0))
---To be specic this is the part I didn't understand---
countif($A$3:A3,$E$2:$E$1000) --- This function returns 0 or 1 if the value exist in $E$2:$E$1000 range.
Then comes
Match(0,countif($A$3:A3,$E$2:$E$1000),0) --- which is generating this value Match(0, 0 or 1, 0) How come
Match function doesn't have a range in the middle. In fact its taking countif array as range. Could anyone
explain this to me?
Reply
Reply
Replies
Deepanshu Bhalla
Reply
Reply
There's a challenge after applying the above formulas. A window pops up which is titled Update Values :"File
Name"
Reply
Reply
Reply
Unknown 30 August 2016 at 06:31
Thank you for your code which is most usefull, need your kind assistance to modify formula in excel to work
with countifs or by using index to return 2 values for example the stage column and user name
Reply
Hi Dipanshu ,
Thanks a lot for posting this - just one thing option 2 gives circular reference error
Reply
Replies
Reply
Reply
Reply
Reply
Taylor Levy 23 January 2017 at 09:11
Thanks for this thorough explanation. For some reason I am getting the same entry (the rst) repeated over the
entire column. Any help would be much appreciated!
Reply
Replies
Deepanshu Bhalla
Reply
I have a quick question perhaps you may help me. I have tried the solution using aggregate function but since
my workbook is huge it is taking forever to load, when I use index and match it is super fast but I am failing to
nd a workaround of ignoring the zero values.
This is a student dataset in a school, so students have to pay a small registration fee which some pay once
like Acc 5014 and some pay in installments as Acc 1047. The thing is the join date starts when the reg fee is
fully paid hence the zeros on 1 and 5 jan 2017.
Thanks
Reply
Add comment
Comment as:
Select prole...
Publish Preview
Kirim