|
楼主 |
发表于 2019-10-17 20:36
|
显示全部楼层
Function ss(txt) '单元格内排序
Dim n As Integer
Dim arr()
n = Len(txt)
ReDim arr(1 To n)
For i = 1 To n
arr(i) = Mid(txt, i, 1)
Next
For i = 1 To n - 1
For j = i + 1 To n
If arr(i) > arr(j) Then
temp = arr(i)
arr(i) = arr(j)
arr(j) = temp
End If
Next
Next
ss = Join(arr, "")
End Function
Function saas(txt) '单元格内去重后计数
Dim n As Integer
Dim arr()
n = Len(txt)
m = n
ReDim arr(1 To n)
For i = 1 To n
arr(i) = Mid(txt, i, 1)
Next
For i = 1 To n - 1
For j = i + 1 To n
If arr(i) > arr(j) Then
temp = arr(i)
arr(i) = arr(j)
arr(j) = temp
End If
Next
Next
For i = 1 To n - 1
If arr(i) = arr(i + 1) Then m = m - 1
Next
saas = m ' Join(arr, "")
End Function
Function sas(txt) '单元格内去重后计数
Dim n As Integer
Dim arr()
n = Len(Replace(txt, Space(1), vbNullString))
m = n
ReDim arr(1 To n)
For i = 1 To n
arr(i) = Mid(txt, i, 1)
Next
For i = 1 To n - 1
For j = i + 1 To n
If arr(i) = arr(j) Then m = m - 1: i = i + 1
Next
Next
sas = m
End Function
|
评分
-
1
查看全部评分
-
|