Dependent Combobox Problem

amoverton2

Board Regular
Joined
May 13, 2021
Messages
77
Office Version
  1. 2016
Platform
  1. Windows
I have a userform with 4 comboboxes, I would like them to be dependent comboboxes with an advanced filter used in the process to whittle down the selection by the 4th box.

I have been watching videos and reading tutorials but I can't find exactly what I want, however I did find one but it returns an error that is not seen in the tutorial video.

Here is the code that returns the error:

Private Sub UserForm_Initialize()

Dim sh As Worksheet
Set sh = Sheets("Pool2")

Dim i As Long
For i = 2 To sh.Range("A10000").End(x1Up).Row (this is usually what the debugger picks on)

If Application.WorksheetFunction.CountIf(sh.Range("A2", "A" & i), sh.Cells(i, 1)) = 1 Then
Me.ComboBox1.AddItem sh.Cells(i, 1)
End If
Next i

End Sub

Here is a snippet of the data being used (the max is 600 rows). The idea is for someone to pick the code, then the rate, then if they qualified, and the last combobox is the name with no duplicates in any of the comboboxes. If there is a way to do it without using an advanced filter that'll be cool. In the original worksheet the columns used below are not A,B,C,D but D (Code), B (Rate), K (Qualified), C (Name). Sorry to make it hard...

Cell Formulas
RangeFormula
A2:A50A2='[Future Sponsorship List.xlsm]Enlisted Sponsor Pool'!D5
B2:B50B2='[Future Sponsorship List.xlsm]Enlisted Sponsor Pool'!B5
C2:C50C2='[Future Sponsorship List.xlsm]Enlisted Sponsor Pool'!K5
D2:D50D2='[Future Sponsorship List.xlsm]Enlisted Sponsor Pool'!C5



Thank you, I really do appreciate the help, and if anyone can tell me why the code I post is returning the error in simple terms that'll be great.
 
In "Sub UserForm_Initialize" the code populates the defined range (col D,B,K,C) into variable va,vb,vc,vd.
Then, for example, when you enter cmbSPONRATE, vb will be filtered by va value that match cmbBBDCODE.Value. The filtered value is assigned to var d (dictionary object) to make it unique.
The process is in this part:

Private Sub cmbSPONRATE_Enter()
.....
For i = LBound(va) To UBound(va)
If UCase(va(i, 1)) = UCase(Me.cmbBBDCODE.Value) Then d(vb(i, 1)) = Empty
Next

Me.cmbSPONRATE.List = toSort(d.Keys)

Then to sort the value in d, the code sends d values to a helper column (pointed by constant xH, in this example is Z1, well Z1 actually is a cell but it's easier to code by using the first cell in the helper column) then sort it. And then the values in the helper column is populated to cmbSPONRATE.List. The process is in Function toSort.

The helper column is a temporary helper column, its values is changed depend on which combobox is changed.
.....


Yes


It's a different problem, you need to start a new thread. ;)
Thanks for the help!!! and here comes a new thread!!
 
Upvote 0

Excel Facts

Square and cube roots
The =SQRT(25) is a square root. For a cube root, use =125^(1/3). For a fourth root, use =625^(1/4).
You're welcome, glad to help & thanks for the feedback.:)
 
Upvote 0

Forum statistics

Threads
1,214,872
Messages
6,122,025
Members
449,060
Latest member
LinusJE

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