3 个解决方案
#1
利用COLLECTION :
Function distinct(ByVal range As range)
On Error Resume Next
Dim i As Integer, j As Integer
Dim x As New Collection
For i = 1 To range.Rows.Count
For j = 1 To range.Columns.Count
x.Add range(i, j), range(i, j)
Next
Next
For i = 1 To x.Count
distinct = distinct & x(i) & ","
Next
distinct = Left(distinct, Len(distinct) - 1)
Set x=nothing
End Function
Function distinct(ByVal range As range)
On Error Resume Next
Dim i As Integer, j As Integer
Dim x As New Collection
For i = 1 To range.Rows.Count
For j = 1 To range.Columns.Count
x.Add range(i, j), range(i, j)
Next
Next
For i = 1 To x.Count
distinct = distinct & x(i) & ","
Next
distinct = Left(distinct, Len(distinct) - 1)
Set x=nothing
End Function
#2
啊,没看明白~~
#3
自定义函数,用法可参考 ttp://blog.csdn.net/northwolves/archive/2005/10/20/509681.aspx
#1
利用COLLECTION :
Function distinct(ByVal range As range)
On Error Resume Next
Dim i As Integer, j As Integer
Dim x As New Collection
For i = 1 To range.Rows.Count
For j = 1 To range.Columns.Count
x.Add range(i, j), range(i, j)
Next
Next
For i = 1 To x.Count
distinct = distinct & x(i) & ","
Next
distinct = Left(distinct, Len(distinct) - 1)
Set x=nothing
End Function
Function distinct(ByVal range As range)
On Error Resume Next
Dim i As Integer, j As Integer
Dim x As New Collection
For i = 1 To range.Rows.Count
For j = 1 To range.Columns.Count
x.Add range(i, j), range(i, j)
Next
Next
For i = 1 To x.Count
distinct = distinct & x(i) & ","
Next
distinct = Left(distinct, Len(distinct) - 1)
Set x=nothing
End Function
#2
啊,没看明白~~
#3
自定义函数,用法可参考 ttp://blog.csdn.net/northwolves/archive/2005/10/20/509681.aspx