[英]Excel VBA Changing Combobox list from static range to dynamic
這應該很簡單,但是我很掙扎。 現在,此代碼有效:
cboCategoryEdit1.List = Sheets(2).Range("A2:A40").Value
我試圖通過更改組合框的填充方式來“清理”我的項目。 我希望它是一個組合框,其范圍只能容納填充的單元格。 這意味着我需要使用最后一行功能。 我將代碼更改為此,並且僅收到“找不到方法或數據成員”的錯誤。 這是我的問題代碼:
Dim i As Range
With Sheets("xRef-Categories")
Set i = .Range("A2:A" & .Range("A" & .Rows.Count).End(xlUp).Row)
End With
Me.cboCategoryEdit1.ListFillRange = i.Address
感謝您對此的任何幫助。
順便說一句:Sheet2是“外部參照類別”
您只需要這個...
With Sheets("xRef-Categories")
Me.cboCategoryEdit1.List = .Range("A2:A" & .Range("A" & .Rows.Count).End(xlUp).Row).Value
End With
您可以像這樣簡化它:
With Sheets("xRef-Categories")
Me.cboCategoryEdit1.List = .Range("A2" , .Range("A" & .Rows.Count).End(xlUp)).Value
End With
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.