手机
当前位置:查字典教程网 >电脑 >Excel教程 >提取Excel不重复值的自定义函数方案
提取Excel不重复值的自定义函数方案
摘要:提取Excel不重复值的自定义函数方案,FunctionMergerRepeat(IndexAsInteger,ParamArrayargl...

提取Excel不重复值的自定义函数方案,Function MergerRepeat(Index As Integer, ParamArray arglist() As Variant)

---------------------------------------------

时间:2008-12-26

理整:宇 bengdeng

功能:获得指定单元格区域或数组中的不重复集合或值

参数说明:

Index:整型,当值小于1时,函数返回一个集合;

大于1且小于不重复项的时,返回一个不重复的值

大于不重复项时,返回空。

arglist():可为单元格区域或数组常量。

----------------------------------------------

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

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

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,},C2:C6))

【提取Excel不重复值的自定义函数方案】相关文章:

Excel统计函数

Excel中排出并列的名次

Excel2007八大常见错误值的含义和解决方法

Excel中双击的妙用

excel幂函数怎么设置

Excel如何自定义数字格式

改变Excel中单元格式次序的方法

Excel批量插入多行的方法

在Excel中自定义函数

Excel打印时自动添加网格线的设置方法

精品推荐
分类导航