Userform dependent combo boxes

jamescooper

Well-known Member
Joined
Sep 8, 2014
Messages
771
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
 

Some videos you may like

Excel Facts

Lock one reference in a formula
Need 1 part of a formula to always point to the same range? use $ signs: $V$2:$Z$99 will always point to V2:Z99, even after copying

baitmaster

Well-known Member
Joined
Mar 12, 2009
Messages
2,037
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?
 

Watch MrExcel Video

Forum statistics

Threads
1,099,353
Messages
5,468,116
Members
406,566
Latest member
MsfStl

This Week's Hot Topics

Top