Unique records in List

haissk

New Member
Joined
Oct 28, 2008
Messages
48
I have an excel file in which say i have some items in Col A
Apple
Banana
Grapes
Banana
Apple
Grapes
Mango
Mango

now i want a create a list dropdown in Cell B1 with unique values from Col A... any help would be appreaciated
 

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.
Try Advance Filter select Unique Values
 
Upvote 0
Copy col A in some other col( say J). Use remove duplicates to get a list of unique items from column A. In cell B1 use data validation to create a list whose input is column J.
 
Upvote 0
There two vba codes to solve the problem.

Code:
Sub EasySol()
Dim LR As Long
 LR = ActiveSheet.Cells(Rows.Count, "A").End(xlUp).Row
    Range("A1:A" & LR).AdvancedFilter Action:=xlFilterCopy, CopyToRange:=Range("J1"), Unique:=True
    
End Sub

Code:
Sub test()
Dim a, e, j(), n As Long
a = Range("a1", Range("a" & Rows.Count).End(xlUp)).Value
Columns("j").ClearContents
If Not IsArray(a) Then
     Range("j1").Value = a: Exit Sub
End If
ReDim j(1 To UBound(a, 1), 1 To 1)
With CreateObject("Scripting.Dictionary")
     .CompareMode = vbTextCompare
     For Each e In a
          If Not IsEmpty(e) And Not .exists(e) Then
               n = n + 1: j(n, 1) = e
               .Add e, Nothing
          End If
    Next
End With
Range("j1").Resize(n).Value = j
End Sub

EasySol is much easier for read and follow.

Biz
 
Upvote 0
Biz - what do I need to add to the easy solution to copy the unique list to J1 on Sheet2, Sheet3, Sheet4 etc?
 
Upvote 0
you can get Unique List By formula
<b>Excel 2007</b><table cellpadding="2.5px" rules="all" style=";background-color: #FFFFFF;border: 1px solid;border-collapse: collapse; border-color: #A6AAB6"><colgroup><col width="25px" style="background-color: #E0E0F0" /><col /><col /><col /></colgroup><thead><tr style=" background-color: #E0E0F0;text-align: center;color: #161120"><th></th><th>A</th><th>B</th><th>C</th></tr></thead><tbody><tr ><td style="color: #161120;text-align: center;">1</td><td style=";">List</td><td style="text-align: right;;"></td><td style=";">List</td></tr><tr ><td style="color: #161120;text-align: center;">2</td><td style=";">Apple</td><td style="text-align: right;;"></td><td style=";">Apple</td></tr><tr ><td style="color: #161120;text-align: center;">3</td><td style=";">Banana</td><td style="text-align: right;;"></td><td style=";">Banana</td></tr><tr ><td style="color: #161120;text-align: center;">4</td><td style=";">Grapes</td><td style="text-align: right;;"></td><td style=";">Grapes</td></tr><tr ><td style="color: #161120;text-align: center;">5</td><td style=";">Banana</td><td style="text-align: right;;"></td><td style=";">Mango</td></tr><tr ><td style="color: #161120;text-align: center;">6</td><td style=";">Apple</td><td style="text-align: right;;"></td><td style=";"></td></tr><tr ><td style="color: #161120;text-align: center;">7</td><td style=";">Grapes</td><td style="text-align: right;;"></td><td style=";"></td></tr><tr ><td style="color: #161120;text-align: center;">8</td><td style=";">Mango</td><td style="text-align: right;;"></td><td style=";"></td></tr><tr ><td style="color: #161120;text-align: center;">9</td><td style=";">Mango</td><td style="text-align: right;;"></td><td style=";"></td></tr></tbody></table><p style="width:3.6em;font-weight:bold;margin:0;padding:0.2em 0.6em 0.2em 0.5em;border: 1px solid #A6AAB6;border-top:none;text-align: center;background-color: #E0E0F0;color: #161120">Sheet5</p><br /><br /><table width="85%" cellpadding="2.5px" rules="all" style=";border: 2px solid black;border-collapse:collapse;padding: 0.4em;background-color: #FFFFFF" ><tr><td style="padding:6px" ><b>Array Formulas</b><table cellpadding="2.5px" width="100%" rules="all" style="border: 1px solid;text-align:center;background-color: #FFFFFF;border-collapse: collapse; border-color: #A6AAB6"><thead><tr style=" background-color: #E0E0F0;color: #161120"><th width="10px">Cell</th><th style="text-align:left;padding-left:5px;">Formula</th></tr></thead><tbody><tr><th width="10px" style=" background-color: #E0E0F0;color: #161120">C2</th><td style="text-align:left">{=IFERROR(<font color="Blue">INDEX(<font color="Red">$A$2:$A$9,MATCH(<font color="Green">0,COUNTIF(<font color="Purple">$C$1:C1,$A$2:$A$9</font>),0</font>)</font>),""</font>)}</td></tr></tbody></table><b>Entered with Ctrl+Shift+Enter.</b> If entered correctly, Excel will surround with curly braces {}.
<b>Note: Do not try and enter the {} manually yourself</b></td></tr></table><br />
 
Upvote 0
Hi u can use the formula given above. With them u need to define the name in name manger for this press ctrl+f3. After that create new name and enter the formula in name manager.

After that in validation part enter the name u define in name manager....this one realy help u....
 
Upvote 0
@Biz:

Hi there. Just curious if I am reading correctly. Is J being oversized?

Thank you,

Mark
 
Upvote 0
Hi GTO,

Yes J is oversized then J is resized by count uniques which is contained in n.

Biz
 
Upvote 0

Forum statistics

Threads
1,224,543
Messages
6,179,429
Members
452,914
Latest member
echoix

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