I have the following code:
Dim RR As Range RR = Sheet90.Range("AA25:AA46") For i = 1 To ComboBox1.ListCount 'Remove an item from the ListBox. ComboBox1.RemoveItem 0 Next i Dim R As Range For Each R In RR.Cells If Len(R.Value) > 0 Then Sheet90.ComboBox1.AddItem (R.Value) End If Next R Obviously, it does not work.
I'm trying to populate a combobox with the non-blank values of a defined array.
Excel VBA does not approve of my methodology, and its error messages are less than helpful.
It says,
Run-time error '91' Object variable or With block variable not set I assume this is some sort of lexical scoping issue, but for the life of me, I can't understand it. Everything is enclosed in a single private SUB, and oddly enough when I just run:
RR = Sheet90.Range("AA25:AA46") For i = 1 To ComboBox1.ListCount 'Remove an item from the ListBox. ComboBox1.RemoveItem 0 Next i it clears the box.
If I Dim RR As Range, everything falls to pieces.
I haven't written vba in ages, so I'm probably making some kind of simple mistake, and I'd really appreciate any guidance.
Thanks!