如果我新增了一個ComboBox3,為了顯示D欄,該如何插入?
原本沒有ComboBox1,ComboBox2的時候是這樣子
Private Sub UserForm_Initialize()
Dim d As Object, A
Set d = CreateObject("Scripting.Dictionary")
With ActiveSheet
For Each A In .Range("d2", .[d2].End(xlDown))
d(A.Value) = ""
Next A
ComboBox3.List = Application.Transpose(d.keys)
End With
End Sub
如果新增一個ComboBox3和ComboBox4做搭配,該如何插入?
原本沒有ComboBox1,ComboBox2的時候是這樣子
Dim d As Object
Private Sub UserForm_Initialize()
Dim A As Range, W As String
Set d = CreateObject("Scripting.Dictionary")
With ActiveSheet
For Each A In .Range("d2", .[d2].End(xlDown))
If d(A.Value) = "" Then
d(A.Value) = A.Offset(, 1).Value
Else
W = "," & d(A.Value) & "," '字典物件內容前後加上 ,
If InStr(W, "," & A.Offset(, 1) & ",") = 0 Then d(A.Value) = d(A.Value) & "," & A.Offset(, 1)
'InStr(w, "," & A.Offset(, 1) & ",") = 0 比對字典物件內容有無A.Offset(, 1)的字串
End If
Next
ComboBox3.List = d.KEYS
End With
End Sub作者: av8d 時間: 2012-7-11 16:37