Userform dependent combo boxes

jamescooper

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

baitmaster

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

Forum statistics

Threads
1,081,415
Messages
5,358,533
Members
400,502
Latest member
price83

Some videos you may like

This Week's Hot Topics

  • VBA (Userform)
    Hi All, I just would like to know why my code isn't working. Here is my VBA code: [CODE=vba]Private Sub OKButton_Click() Dim i As Integer...
  • List box that changes fill color
    Hello, I have gone through so many pages trying to figure this out. I have a 2020 calendar that depending on the day needs to have a certain...
  • Remove duplicates and retain one. Cross-linked cases
    Hi all I ran out of google keywords to use and still couldn't find a reference how to achieve the results of a single count. It would be great if...
  • VBA Copy and Paste With Duplicates
    Hello All, I'm in need of some input. My VBA skills are sub-par at best. I've assembled this code from basic research and it works but is...
  • Macro
    is it possible for a macro to run if the active cell value is different to the value above it
  • IF DATE and TIME
    I currently use this to check if date has passed but i also need to set a time on it too. Is it possible? [CODE=vba]=IF(B:B>TODAY(),"Not...
Top