A custom function scheme that extracts Excel values without duplicates

Source: Internet
Author: User

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))

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.