dyslexicgruffalo
dyslexicgruffalo

Reputation: 374

VBA - Filling Combo Box with Dynamic Range

I have a problem with my ComboBox1, I am trying to make some hidden filters to make viewing lots of data easier and i want to select what i filter out via a combo box, where the input selection is part of this processed data.

Here is some code that i tried to write for populating the ComboBox but it comes up with an error saying that it is the wrong use of Method.

Sub ComboBox1_DropButton_Click()
Dim i As Range

With Sheets("Pipe 16")
Set i = .Range("G5:G" & .Range("G" & .Rows.Count).End(xlUp).Row)
End With
Me.ComboBox1.ListFillRange = "i"

End Sub

Any help appreciated.

EDIT

this cannot be answered by the answers shown in Dynamically set ListFillRange in Excel ComboBox using VBA

Upvotes: 0

Views: 16945

Answers (2)

Elie Wakim
Elie Wakim

Reputation: 1

ComboBox1.RowSource = "" ComboBox1.List = ActiveSheet.Range("B3", ActiveSheet.Range("B" & Rows.Count).End(xlUp)).Value

Upvotes: 0

user6432984
user6432984

Reputation:

ListFillRange accept the range's address not the range itself.

Sub ComboBox1_DropButton_Click()

    Dim i As Range

    With Sheets("Pipe 16")
        Set i = .Range("G5:G" & .Range("G" & .Rows.Count).End(xlUp).Row)
    End With
    Me.ComboBox1.ListFillRange = i.Address

End Sub

Upvotes: 4

Related Questions