VBA 如何提取不重复数据?
可以用以下两种方法
Sub 不重复数据字典法()
Dim d As Object
Dim lRow As Long
Dim i As Long
Dim str As Variant
Dim strKey As String
Set d =
CreateObject("scripting.dictionary")
lRow = Range("A65536").End(xlUp).Row
' lRow = Cells(Rows.Count,1).End(xlUp).Row
str = Range("A1:A" & lRow)
For i = 1 To lRow
strKey =
CStr(str(i, 1))
If Not d.exists(strKey) Then
d.Add strKey, strKey
End If
Next i
Range("D1").Resize(UBound(d.keys) + 1, 1) =
Application.Transpose(d.keys)
End Sub
***************
Sub 高级筛选()
Dim lRow
As Long
lRow =
Range("A65536").End(xlUp).Row
'lRow =
Cells(Rows.Count,1).End(xlUp).Row
Range("A1:A" & lRow).AdvancedFilter Action:=xlFilterCopy,
CopyToRange:=Range("F1"), Unique:=True
End Sub
加载中,请稍候......