標題:
[原創]
利用字典去除重複內容
[打印本頁]
作者:
sunnyso
時間:
2013-4-11 18:50
標題:
利用字典去除重複內容
=IFERROR(UNIQUE($C$1:$C$10,ROW(A1)),"")
[attach]14640[/attach]
code of UNIQUE function
Function UNIQUE(source As Range, num As Integer)
Dim newArray, myArray As Variant
rows_num = source.Rows.Count
myArray = Range(source.Address).Value
Set Dic = CreateObject("scripting.dictionary")
For i = 1 To rows_num
Dic((myArray(i, 1))) = ""
Next
arr = Dic.Keys
UNIQUE = arr(num - 1)
End Function
複製代碼
作者:
sunnyso
時間:
2013-4-11 22:16
修改Code 可以
略過空白
Function UNIQUE(source As Range, num As Integer)
Dim newArray, myArray As Variant
rows_num = source.Rows.Count
myArray = Range(source.Address).Value
Set Dic = CreateObject("scripting.dictionary")
For i = 1 To rows_num
Dic(CStr(myArray(i, 1))) = ""
Next
arr = Dic.Keys
UNIQUE = arr(num - 1)
End Function
複製代碼
作者:
sunnyso
時間:
2013-4-11 22:39
回復
2#
sunnyso
更新Code
略過空白
Function UNIQUEp(source As Range, num As Integer)
Dim newArray, myArray As Variant
rows_num = source.Rows.Count
'myArray = Range(Cells(source.Row, source.Column), Cells(source.Row + rows_num - 1, source.Column)).Value
myArray = Range(source.Address).Value
Set Dic = CreateObject("scripting.dictionary")
For i = 1 To rows_num
If myArray(i, 1) <> "" Then
Dic((myArray(i, 1))) = ""
End If
Next
arr = Dic.Keys
UNIQUEp = arr(num - 1)
End Function
複製代碼
歡迎光臨 麻辣家族討論版版 (http://forum.twbts.com/)