excel两个单元格输入的内容不同为何显示重复项,而且只有其中一个显示重复,怎么处理。无法条件引用
1个回答
展开全部
楼上的答案可以说是对的,但如果要排序,最好是使用自定义函数不晌敬完成。
自定义函数代码如下:
Function SortIf(ByVal rg1 As Range, ByVal rg2 As Range)
Dim rg As Range, rng As Range, i%, k%, s%, n%, arr()
Set rg = Range(rg1, rg2)
For Each rng In rg
For i = 1 To Len(rng)
s = Mid(rng, i, 1)
On Error GoTo l
For j = 0 To UBound(arr())
答蔽 If s = arr(j) Then GoTo ll
Next
l:
ReDim Preserve arr(k)
arr(k) = s
k = k + 1
ll:
Next
Next
For i = 0 To UBound(arr()) - 1
m = i
For j = i + 1 To UBound(arr())
If arr(j) > arr(m) Then
宴举慎 m = j
End If
Next
If m <> i Then
n = arr(i)
arr(i) = arr(m)
arr(m) = n
End If
Next
For i = 0 To UBound(arr())
SortIf = SortIf & arr(i)
Next
End Function
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询