to find unique values from a column

saurabh

Board Regular
Joined
Feb 28, 2003
Messages
69
i have to find unique values form a column to show them in a combo?

please help

thanks in advance
 

Excel Facts

What is =ROMAN(40) in Excel?
The Roman numeral for 40 is XL. Bill "MrExcel" Jelen's 40th book was called MrExcel XL.
This "Question" is extremely vague... try to give more detailed info re what you're trying to do & you'll get better answers...
 
Upvote 0
Try:

Private Sub xyz()
Dim Model As Object
Dim cell As Range

Set Model = CreateObject("Scripting.Dictionary")
For Each cell In Range("Models")
If Not Model.exists(cell.Value) Then
Model.Add cell.Value, cell.Value
cboModel.AddItem cell.Value
End If
Next
End Sub

The dictionary object is similar to a single dimension array, but it has a exist method, which will return a true or false if a variable exist as a member. In the above scenaria, it loops through cells in a range and check if the value exist in the dict. object then adds if it isn't (so it will be there the next time it checks and avoids duplicates) and adds it to the combo box.
 
Upvote 0

Forum statistics

Threads
1,214,641
Messages
6,120,692
Members
448,979
Latest member
DET4492

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