Private Sub CommandButton1_Click() '优先考虑
'采用 高级筛选
获取设备型号库中E列不重复值,即部门名
Application.ScreenUpdating = False
Sheets("temp").Cells.Clear
Me.ComboBox1.Clear
Dim
p&, t&
p =
Sheets("设备型号库").[a65536].End(xlUp).Row
Sheets("设备型号库").Range("e1:e" & p).AdvancedFilter
Action:=xlFilterCopy, _
CopyToRange:=Sheets("temp").Range("a1"), Unique:=True
'注意:高级筛选会把标题行单独放在第一行。
For i = 2 To
Sheets("temp").[a65536].End(xlUp).Row
If Range("a" & i) <>
"" Then Me.ComboBox1.AddItem Range("a" & i)
Next i
Application.ScreenUpdating = True
End Sub
Private Sub CommandButton2_Click()
' '采用
引用collection对象 获取设备型号库中E列不重复值,即部门名
Application.ScreenUpdating = False
Sheets("temp").Cells.Clear
Me.ComboBox1.Clear
Dim
t&
Dim
i&, j&, k&,
p&, c&, arr, arr1()
Dim h As New
Collection
[k:k].ClearContents
p =
Sheets("设备型号库").[a65536].End(xlUp).Row
arr =
Sheets("设备型号库").Range("e2:e" & p)
On Error
Resume Next
For i = 1 To
p
h.Add arr(i, 1), CStr(arr(i, 1))
Next i
Err.Clear
On Error
GoTo 0
c =
h.Count
ReDim arr1(1
To c, 0)
For i = 1 To
c
arr1(i, 0) = h(i)
If arr1(i, 0) <> "" Then
Me.ComboBox1.AddItem arr1(i, 0)
Next i
Sheets("temp").Range("a1:a" & c) = arr1
Application.ScreenUpdating = True
End Sub
加载中,请稍候......