|
求助:
如何将单元格区域中的不重复值自动填入Cobobox中?
详见附件,谢谢!!
回复 走进EXCEL 的帖子
- Private Sub UserForm_Initialize()
- Dim arr
- Dim i As Long
- Dim j As Long
- Dim D As Object '定义字典步骤1
- Set D = CreateObject("scripting.dictionary") '定义字步骤2
- With ListView1
- .ColumnHeaders.Add , , "姓名", 38
- .ColumnHeaders.Add , , "等级", Width / 6
- .ColumnHeaders.Add , , "排名", Width / 6
- .View = lvwReport 'listivew的显示格式为报表格式
- .Gridlines = True '显示网格线
- .FullRowSelect = True '允许整行选中
- End With
- ' Set D = CreateObject("Scripting.Dictionary")
- With ComboBox1
- arr = Range("k1:M" & Range("a65536").End(xlUp).Row)
- For j = 1 To 3
- For i = 1 To UBound(arr)
- If arr(i, j) <> "" Then
- D(arr(i, j)) = ""
- End If
- Next i
- Next j
- ComboBox1.List() = D.keys
- End With
- ComboBox1.ListIndex = 0
- End Sub
复制代码
|
|