Hi
I am looking for a way to populate a user form combo box with only unique entries from a table. Any help would be greatly appreciated!
test.jpg
Regards, Steve
Hi
I am looking for a way to populate a user form combo box with only unique entries from a table. Any help would be greatly appreciated!
test.jpg
Regards, Steve
We kind-of need more info. For instance...
1) What entries do you want in the ComboBox?
2) What determines which entries go into the ComboBox and when?
Attaching the workbook is great, however, when I open the UserForm, the ComboBox in the UserForm shows exactly what you have in the image.
1N73LL1G3NC3 15 7H3 4B1L17Y 70 4D4P7 70 CH4NG3 - 573PH3N H4WK1NG
You don't have to add Rep if I have helped you out (but it would be nice), but please mark the thread as SOLVED if your issue is resolved.
Tom
Apologies, so my idea was that for any new item you can manually type a new location or supplier or you can select a previously used location or supplier that has been entered previously, my only issue is the combo box displays the whole location and supplier columns whereas i only want it to supply unique entries. For example in the image the combo box displays fridge 1 twice because it appears on the location column twice, i only want it to apear in the list once. Hope that makes sense and thanks for the reply!
Regards, Steve
I'm a beginner at Excel so I assume some of the experts on here might have a simpler solution, but this might help (I assume that the values in the Location column are sorted in alphabetical order):
Set Location = .Range("FridgeTable[Location]")Please Login or Register to view this content.
' Add 1st value of Location range to combo box
ComboBox1.AddItem (Location(1))
' Set 1st value in Location to oldVal so we can check for duplicates in the loop
oldVal = Location(1)
' Loop through each Cell in Location range and add only unique values to the combobox
For i = 2 To Location.Count
newVal = Location(i)
' Check if cell's value is a duplicate. If it is, don't add it to the combobox
If newVal <> oldVal Then
' Add value to combobox
ComboBox1.AddItem (newVal)
' Set current Cell value to oldVal so we can check for duplicates in the next
' iteration of the loop
oldVal = newVal
End If
Next
Please Login or Register to view this content.
Last edited by JaguerRhye; 02-17-2016 at 01:04 PM.
Remove RowSource from both Comboboxes.
Please Login or Register to view this content.
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks