|
大概这样的,你可以根据实际需要修改
Me.ListBox1.Clear
Dim arr, RowItem As Integer
Dim arr2(), TargetCount As Integer
arr = Sheet7.UsedRange.Value
For RowItem = 1 To UBound(arr)
If arr(RowItem, 1) = ComboBox1.Value Then
TargetCount = TargetCount + 1
ReDim Preserve arr2(1 To 7, 1 To TargetCount + 1)
arr2(1, TargetCount) = arr(RowItem, 1)
arr2(2, TargetCount) = arr(RowItem, 2)
arr2(3, TargetCount) = arr(RowItem, 3)
arr2(4, TargetCount) = arr(RowItem, 4)
arr2(5, TargetCount) = arr(RowItem, 5)
arr2(6, TargetCount) = arr(RowItem, 6)
arr2(7, TargetCount) = arr(RowItem, 7)
End If
Next RowItem
Me.ListBox1.ColumnCount = 7
Me.ListBox1.ColumnWidths = "50,80,80,80,80,100,100"
Me.ListBox1.List = WorksheetFunction.Transpose(arr2) |
|