2016-07-14 147 views
0

我有一個問題,我的組合框1,我想做一些隱藏的過濾器,使查看大量的數據更容易,我想選擇什麼,我通過組合框篩選出來,其中輸入選擇是這個處理數據的一部分。VBA - 動態範圍填充組合框

這裏有一些代碼,我試圖寫入填充組合框,但它出現了一個錯誤,說它是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 

任何幫助表示讚賞。

編輯

這不能由Dynamically set ListFillRange in Excel ComboBox using VBA

+0

的[動態使用VBA設置ListFillRange在Excel中組合框(http://stackoverflow.com/questions/4200712/dynamically-set-listfillrange-in-excel-combobox-using-vba) – Dave

+0

有無可能的複製只是嘗試了在這裏建議什麼,它不工作@Dave – lewisthegruffalo

+0

Try Me.ComboBox1.List = i.Value –

回答

2

ListFillRange所示的答案回答接受的範圍內的地址不是自己的範圍內。

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