我编写此代码是为了将工作表中的信息放入用户窗体中的列表框。这是我编写的代码,但它告诉我有些内容超出了范围,尽管我无法确定哪些内容超出了范围。
Private Sub PopulateSearchBox()
Dim wsTL2 As Worksheet
Set wsTL2 = Worksheets("Task List2")
Dim last_row As Long
last_row = wsTL2.Cells(wsTL2.Rows.Count, "C").End(xlUp).Row 'the last populated row in C so it covers the whole range of data that I need.
With Me.searchBox
.ColumnHeads = True
.ColumnCount = 3
.ColumnWidths = "100,100,100"
.RowSource = "Task List2!A1:C" & last_row
End With
End Sub
1条答案
按热度按时间bq3bfh9z1#
ComboBox
的RowSource
属性需要地址字符串。因此,您可以执行以下操作:虽然很可能你会更喜欢
.List
属性?