使用筛选的数据填充Excel VBA列表框,可以通过以下步骤实现:
Dim ws As Worksheet
Set ws = ThisWorkbook.Sheets("Sheet1")
Dim rng As Range
Set rng = ws.Range("A1:C10")
Dim data As Variant
data = rng.Value
Dim i As Long
For i = 1 To UBound(data, 1)
Me.ListBox1.AddItem data(i, 1) '假设要将第一列数据填充到列表框中
Next i
完整的VBA代码示例:
Private Sub UserForm_Initialize()
Dim ws As Worksheet
Set ws = ThisWorkbook.Sheets("Sheet1")
Dim rng As Range
Set rng = ws.Range("A1:C10")
Dim data As Variant
data = rng.Value
Dim i As Long
For i = 1 To UBound(data, 1)
Me.ListBox1.AddItem data(i, 1) '假设要将第一列数据填充到列表框中
Next i
End Sub
以上代码将会将筛选后的数据填充到名为"ListBox1"的列表框中。你可以根据实际情况修改代码中的工作表名称、数据范围和列表框名称。
对于Excel VBA列表框的更多信息和使用方法,你可以参考腾讯云的Excel VBA开发文档:Excel VBA开发指南。
领取专属 10元无门槛券
手把手带您无忧上云