嘿,我已经写了这个宏,它可以编译但没有达到它的目标
Private Sub UserForm_Initialize()
Dim r As Range
With CreateObject("Scripting.Dictionary")
.CompareMode = vbTextCompare
For Each r In Sheets("Ticket").Range("e2:e200")
If (Not IsEmpty(r.Value)) * (Not .exists(r.Value)) Then
Me.Trade.AddItem r.Value
.Add r.Value, Nothing
End If
Next
End With
Dim s As Range
Dim t As Range
With CreateObject("Scripting.Dictionary")
.CompareMode = vbTextCompare
For Each s In Sheets("Ticket").Range("c2:c200")
For Each t In Sheets("Ticket").Range("e2:e200")
If (Not IsEmpty(s.Value)) * (Not .exists(s.Value)) And t.Value = UCase(Trade.Value) Then
Me.Client.AddItem s.Value
.Add s.Value, Nothing
End If
Next
Next
End With
End Sub
第一部分工作完美,它从 E 列中选择没有重复的值并将其放入组合框中。问题在第二部分。如果列 E 上的值是我在组合框 1 中选择的值,我想选择不重复列 C 中的值。谢谢你