|
发表于 2013-12-5 13:03
|
显示全部楼层
本楼为最佳答案
- Private Sub ComboBox1_Change()
- CommandButton1.Enabled = False
- For i = 1 To 30
- Controls("Label" & i).Caption = ""
- Next
- Set d = CreateObject("scripting.dictionary")
- With Sheets("3")
- HX = .Range("a65536").End(xlUp).Row
- arr = .Range("a2:c" & HX)
- End With
- If b Then Exit Sub
- n = 0
- For i = 1 To UBound(arr)
- If arr(i, 3) = ComboBox1.Value Then
- n = n + 1
- ReDim Preserve arr2(1 To 3, 1 To n)
- For j = 1 To 3
- arr2(j, n) = arr(i, j)
- Next
- End If
- Next
- If n >= 10 Then CommandButton1.Enabled = True
- n = 1
- cyj
- End Sub
- Private Sub CommandButton1_Click()
- For i = 1 To 30
- Controls("Label" & i).Caption = ""
- Next
- If n > UBound(arr2, 2) Then n = 1
- cyj
- End Sub
- Private Sub UserForm_Initialize()
- Set d = CreateObject("scripting.dictionary")
- With Sheets("3")
- HX = .Range("a65536").End(xlUp).Row
- arr = .Range("a2:c" & HX)
- End With
- For x = 1 To UBound(arr)
- If Not d.exists(arr(x, 3)) Then d.Add arr(x, 3), ""
- Next
- Me.ComboBox1.Clear
- Me.ComboBox1.List = d.keys
- End Sub
- Sub cyj()
- Do Until k = 10 Or n > UBound(arr2, 2)
- k = k + 1
- Controls("Label" & k).Caption = arr2(1, n)
- Controls("Label" & k + 10).Caption = arr2(2, n)
- Controls("Label" & k + 20).Caption = arr2(3, n)
- n = n + 1
- Loop
- End Sub
复制代码 |
|