A custom function scheme that extracts Excel values without duplicates, function mergerrepeat (Index as Integer, ParamArray arglist () as Variant)
---------------------------------------------
' Time: 2008-12-26
' Finishing: Yu Bengdeng
' function: Get a distinct set or value from a specified range of cells or array
' Parameter description:
' Index: Integral type, the value is less than 1 o'clock, the function returns a set;
' is greater than 1 and is less than duplicates, returns a value that is not repeated
' is empty when ' is greater than the duplicate item.
' ArgList (): Can be a range of cells or an array constant.
----------------------------------------------
Dim notrepeat as Object, tstr as String
Set notrepeat = CreateObject ("Scripting.Dictionary")
For all Arg in arglist
For all 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
Here are some examples of applications to illustrate the application of this function.
1, return the number of A1:A10 values.
=counta (Mergerrepeat (0,A1:A10))
2. List the a1:a10 values of the B1 in column B from the beginning of the grid.
Set the formula in B1:
=mergerrepeat (ROW (), $A $: $A $)
and fill it down.
3, to find multiple areas (can not be continuous) Addends group of the number of repetitions.
=counta (Mergerrepeat (0,a1:a6,{"abc", "Excel Bar", 1, "excelba.com"},c2:c6))