第3个问题需要加两句:- Private Sub UserForm_Initialize()
- Dim arr, i&
- Set d = CreateObject("scripting.dictionary")
- arr = Sheet5.Range("a1").CurrentRegion
- For i = 1 To UBound(arr)
- s = arr(i, 1)
- If Not d.Exists(s) Then
- d(s) = arr(i, 2)
- Else
- If InStr("," & d(s) & ",", "," & arr(i, 2) & ",") = 0 Then d(s) = d(s) & "," & arr(i, 2)
- End If
- s = s & vbTab & arr(i, 2)
- If Not d.Exists(s) Then
- d(s) = arr(i, 3)
- Else
- If InStr("," & d(s) & ",", "," & arr(i, 3) & ",") = 0 Then d(s) = d(s) & "," & arr(i, 3)
- End If
- s = s & vbTab & arr(i, 3)
- If Not d.Exists(s) Then
- d(s) = arr(i, 4)
- Else
- If InStr("," & d(s) & ",", "," & arr(i, 4) & ",") = 0 Then d(s) = d(s) & "," & arr(i, 4)
- End If
- Next
- ComboBox1.List = Filter(d.Keys, vbTab, False)
- ComboBox1.Style = fmStyleDropDownList
- ComboBox2.Style = fmStyleDropDownList
- End Sub
复制代码 |