Userform dependent combo boxes

jamescooper

Well-known Member
Joined
Sep 8, 2014
Messages
840
Have the following code to try that attempts to allow you to use the drop down in a userform which is dependent on the other. It is setup with an advanced filter in the spreadsheet. The problem I am encountering is that nothing shows in the dropdown box (combo box1), any ideas?

Thanks.

Code:
Private Sub ComboBox1_Change()


Dim r As Integer


r = 2


Range("F2").Value = ComboBox1.Value


Columns("C:D").AdvancedFilter Action:=xlFilterCopy, CriteriaRange:=Range( _
 "F1:F2"), CopyToRange:=Range("H1:I1"), Unique:=False


ComboBox1.Clear


Do Until Cells(r, 9).Value = ""


ComboBox1.AddItem Cells(r, 9).Value
 r = r + 1


Loop


End Sub
 

Excel Facts

VLOOKUP to Left?
Use =VLOOKUP(A2,CHOOSE({1,2},$Z$1:$Z$99,$Y$1:$Y$99),2,False) to lookup Y values to left of Z values.
Put a break point on your DO line and then use F8 to step through the code. Have the Locals window visible to help monitor your variables

What is not happening as expected? Is there data appearing in cell I2 when you first hit this line of code? Is this reflected in the value of Cells(r,9).value when you hover the mouse over it? What about on any subsequent iterations of the loop?
 
Upvote 0

Forum statistics

Threads
1,223,885
Messages
6,175,186
Members
452,615
Latest member
bogeys2birdies

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