amoverton2
Board Regular
- Joined
- May 13, 2021
- Messages
- 77
- Office Version
- 2016
- Platform
- 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...
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.
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 | ||
---|---|---|
Range | Formula | |
A2:A50 | A2 | ='[Future Sponsorship List.xlsm]Enlisted Sponsor Pool'!D5 |
B2:B50 | B2 | ='[Future Sponsorship List.xlsm]Enlisted Sponsor Pool'!B5 |
C2:C50 | C2 | ='[Future Sponsorship List.xlsm]Enlisted Sponsor Pool'!K5 |
D2:D50 | D2 | ='[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.