Sub Uniquedata()
Dim EachCell As Range
'Creat UniqDicictionary object
Set UniqDic = CreateObject("Scripting.Dictionary")
'Traverse selected area
For Each EachCell In Range("A2:C11")
'Judge whether each cell is NULL
If EachCell <> "" Then
'Add key and value into UniqDic if UniqDic dont' have value of this cell
If Not UniqDic.exists(EachCell.Value) Then UniqDic.Add EachCell.Value, EachCell.Value
End If
Next
'clear content what you select
Range("F2:F" & Range("F2").End(xlDown).Row).ClearContents
'input unique data into column you select
Range("F2").Resize(UniqDic.Count) = WorksheetFunction.Transpose(UniqDic.Items)
End Sub
VBA 获取多列不重复值
最新推荐文章于 2023-10-24 15:24:30 发布