|
[广告] Excel易用宝 - 提升Excel的操作效率 · Excel / WPS表格插件 ★ 免费下载 ★ ★ 使用帮助★
Private Sub ComboBox1_Change()
Dim ar As Variant
Dim br()
With Sheets("汇总")
r = .Cells(Rows.Count, 1).End(xlUp).Row
ar = .Range("a2:r" & r)
End With
ReDim br(1 To UBound(ar), 1 To UBound(ar, 2))
lh = 2
zd = ComboBox1.Text
For i = 2 To UBound(ar)
If Trim(ar(i, lh)) <> "" Then
If Trim(ar(i, lh)) = zd Then
n = n + 1
For j = 1 To UBound(ar, 2)
br(n, j) = ar(i, j)
Next j
End If
End If
Next i
If n = "" Then MsgBox "没有所选条件的数据": Exit Sub
With Me.ListBox1
.Clear
.List = br
End With
End Sub
Private Sub ComboBox2_Change()
Dim ar As Variant
Dim br()
With Sheets("汇总")
r = .Cells(Rows.Count, 1).End(xlUp).Row
ar = .Range("a2:r" & r)
End With
ReDim br(1 To UBound(ar), 1 To UBound(ar, 2))
lh = 3
zd = ComboBox2.Text
For i = 2 To UBound(ar)
If Trim(ar(i, lh)) <> "" Then
If Trim(ar(i, lh)) = zd Then
n = n + 1
For j = 1 To UBound(ar, 2)
br(n, j) = ar(i, j)
Next j
End If
End If
Next i
If n = "" Then MsgBox "没有所选条件的数据": Exit Sub
With Me.ListBox1
.Clear
.List = br
End With
End Sub
Private Sub ComboBox3_Change()
Dim ar As Variant
Dim br()
With Sheets("汇总")
r = .Cells(Rows.Count, 1).End(xlUp).Row
ar = .Range("a2:r" & r)
End With
ReDim br(1 To UBound(ar), 1 To UBound(ar, 2))
lh = 6
zd = ComboBox3.Text
For i = 2 To UBound(ar)
If Trim(ar(i, lh)) <> "" Then
If Trim(ar(i, lh)) = zd Then
n = n + 1
For j = 1 To UBound(ar, 2)
br(n, j) = ar(i, j)
Next j
End If
End If
Next i
If n = "" Then MsgBox "没有所选条件的数据": Exit Sub
With Me.ListBox1
.Clear
.List = br
End With
End Sub
Private Sub CommandButton1_Click()
Worksheets("汇总").Select
With Sheets("汇总")
r = .Cells(Rows.Count, 1).End(xlUp).Row
ar = .Range("a2:r" & r)
End With
ListBox1.List = ar
End Sub
Private Sub CommandButton2_Click()
Unload Me
End Sub
Private Sub UserForm_Initialize()
Dim nRow%, Arr()
Dim ds As Object
Set ds = CreateObject("Scripting.Dictionary")
Set d = CreateObject("Scripting.Dictionary")
Set dc = CreateObject("Scripting.Dictionary")
With Worksheets("汇总")
nRow = .Range("a1048576").End(xlUp).Row
Arr = .Range("a1:f" & nRow).Value
End With
For i = 3 To nRow
If Trim(Arr(i, 2)) <> "" Then
ds(Arr(i, 2)) = ""
End If
If Trim(Arr(i, 3)) <> "" Then
d(Arr(i, 3)) = ""
End If
If Trim(Arr(i, 6)) <> "" Then
dc(Arr(i, 6)) = ""
End If
Next
Me.ComboBox1.List = ds.keys
Me.ComboBox2.List = d.keys
Me.ComboBox3.List = dc.keys
ListBox1.ColumnCount = 18
Call CommandButton1_Click
End Sub |
评分
-
1
查看全部评分
-
|