|
[广告] Excel易用宝 - 提升Excel的操作效率 · Excel / WPS表格插件 ★ 免费下载 ★ ★ 使用帮助★
代码如下。。。
Private Sub ComboBox1_Change()
Dim myarr As Variant, mybrr As Variant, mydic As Object, i As Integer, d, n()
myarr = Sheet2.Range("C6:C" & Range("C6").End(xlDown).Row) 'A列装入字典
mybrr = Sheet2.Range("D6:D" & Range("D6").End(xlDown).Row) 'B列装入字典
Set mydic = CreateObject("scripting.dictionary") '定义字典mydic As Object
For i = 1 To UBound(myarr)
mydic(myarr(i, 1)) = "" 'A列重复的值赋为1
Next i
For i = 1 To UBound(mybrr)
mydic(mybrr(i, 1)) = ""
Next i
ComboBox1.List = mydic.keys
End Sub
'
Private Sub UserForm_Initialize() '窗体初始化
Dim myarr As Variant, mybrr As Variant, mydic As Object, i As Integer, d, n()
myarr = Sheet2.Range("C6:C" & Range("C6").End(xlDown).Row) 'A列装入字典
mybrr = Sheet2.Range("D6:D" & Range("D6").End(xlDown).Row) 'B列装入字典
Set mydic = CreateObject("scripting.dictionary") '定义字典mydic As Object
For i = 1 To UBound(myarr)
mydic(myarr(i, 1)) = "" 'A列重复的值赋为1
Next i
For i = 1 To UBound(mybrr)
mydic(mybrr(i, 1)) = ""
Next i
ComboBox1.List = mydic.keys
End Sub
|
评分
-
1
查看全部评分
-
|