|
[广告] Excel易用宝 - 提升Excel的操作效率 · Excel / WPS表格插件 ★ 免费下载 ★ ★ 使用帮助★
Private Sub listbox1_Change()
Application.ScreenUpdating = False
Dim ar As Variant
With Sheets("报价明细")
r = .Cells(Rows.Count, 1).End(xlUp).Row
ar = .Range("a1:m" & r)
End With
For i = 0 To ListBox1.ListCount - 1
If ListBox1.Selected(i) = True Then
mc = ListBox1.List(i, 2)
Exit For
End If
Next i
If mc = "" Then Exit Sub
Dim arr()
ReDim arr(1 To UBound(ar), 1 To UBound(ar, 2))
n = 1
For j = 1 To UBound(ar, 2)
arr(n, j) = ar(1, j)
Next j
For i = 2 To UBound(ar)
If Trim(ar(i, 3)) = Trim(mc) Then
n = n + 1
For j = 1 To UBound(ar, 2)
arr(n, j) = ar(i, j)
Next j
End If
Next i
If n = "" Then Exit Sub
With ListBox2
.Clear
.ColumnCount = 13
.List = arr
End With
Application.ScreenUpdating = True
End Sub |
|