Populate userform combobox with unique values from a range

soood

Board Regular
Joined
Feb 25, 2009
Messages
81
Hi all, I have a user form with combobox19 that I need to fill with only the unique values from sheet "maintenance" C2:c500.

Thanks for any help!
 

Excel Facts

How to create a cell-sized chart?
Tiny charts, called Sparklines, were added to Excel 2010. Look for Sparklines on the Insert tab.
I couldn't use what you sent, I couldn't figure out how to adapt it to what I needed but I thank you nonetheless because while looking at it I found what to do. I took the original code on the thread top populate combo box #1. Once I selected the value in Combo Box #1 I dumped that value back into the spreadsheet to the right of the source data to become Criteria #1. Then used advanced filter and dumped the filtered data further to the right of the source data. Then in the filtered data I used the original code to populate Combo Box #2. The value from Combo Box #2 dumped into the spreadsheet to the right of Criteria #1 to become Criteria #2. Then used advanced filter again to filter the original list using both Criteria's and then dump the filtered data into the filtered table off to the right. Then used the original code to populate Combo Box #3. Lather, rinse and repeat as needed. The irony is that I've used advanced filters before in macros and did not even think about it when I made reference to using filters exactly like in Excel. [Insert sound of Homer Simpson saying 'Doh!]. Thank you everyone for the help.
 
Upvote 0
Hi,

try

Code:
Private Sub UserForm_Initialize()

Dim v, e
With Sheets("maintenance").Range("c2:c500")
    v = .Value
End With
With CreateObject("scripting.dictionary")
    .comparemode = 1
    For Each e In v
        If Not .exists(e) Then .Add e, Nothing
    Next
    If .Count Then Me.ComboBox19.List = Application.Transpose(.keys)
End With
End Sub

HTH

Your code works perfectly, Would you please explain a bit about dictionary and the loop. Please !
 
Upvote 0
I used advanced filters off the side of the table with all of the drop down options to make this happen. Each drop down activates advanced filters to run based on anything filled into the various drop downs. It works like a dream except when you it’s trying to populate a single value into a drop down. The code I used it doesn’t like that so I forced it to also populate a blank cell below it when there is only 1 item to populate it and that fixed it.
 
Upvote 0
Hi,
special thanks to mr. krishnakumar your code was exactly I was looking for it works like charm ! thankyou so much also
I was wondering if the results achieved can be sorted alphbetically or not
 
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,181
Members
453,022
Latest member
Mohamed Magdi Tawfiq Emam

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