生活已是百般艰难,为何不努力一点。下面图老师就给大家分享提取Excel不重复值的自定义函数方案,希望可以让热爱学习的朋友们体会到设计的小小的乐趣。
【 tulaoshi.com - Excel教程 】
提取Excel不重复值的自定义函数方案,Function MergerRepeat(Index As Integer, ParamArray arglist() As Variant)
---------------------------------------------
’时间:2008-12-26
’理整:宇 bengdeng
’功能:获得指定单元格区域或数组中的不重复集合或值
’参数说明:
’Index:整型,当值小于1时,函数返回一个集合;
’ 大于1且小于不重复项的时,返回一个不重复的值
’ 大于不重复项时,返回空。
’arglist():可为单元格区域或数组常量。
(本文来源于图老师网站,更多请访问http://www.tulaoshi.com)----------------------------------------------
Dim NotRepeat As Object, tStr As String
Set NotRepeat = CreateObject("Scripting.Dictionary")
For Each arg In arglist
For Each rRan In arg
If TypeName(rRan) = "Range" Then
If rRan.Value "" Then NotRepeat(rRan.Value) = 0
Else
NotRepeat(rRan) = 0
End If
(本文来源于图老师网站,更多请访问http://www.tulaoshi.com)Next
Next
If Index 1 Then
MergerRepeat = NotRepeat.keys
ElseIf Index = NotRepeat.Count Then
arr = NotRepeat.keys
MergerRepeat = arr(Index - 1)
Else
MergerRepeat = ""
End If
(本文来源于图老师网站,更多请访问http://www.tulaoshi.com)End Function
下面用几个应用的实例,来说明该函数的应用。
1、返回A1:A10中不重复值的个数。
=COUNTA(MergerRepeat(0,A1:A10))
2、在B列从B1格开始列出A1:A10的不重复数值。
在B1格设定公式:
=MergerRepeat(ROW(),$A$1:$A$10)
并向下填充。
3、求多个区域(可以不连续)加数组的不重复个数。
=COUNTA(MergerRepeat(0,A1:A6,{"abc","Excel吧",1,"excelba.com"},C2:C6))
来源:http://www.tulaoshi.com/n/20160220/1647580.html
看过《提取Excel不重复值的自定义函数方案》的人还看了以下文章 更多>>