+ Reply to Thread
Results 1 to 12 of 12

How to find all unique, matching values betwen two arrays of cells

  1. #1
    Registered User
    Join Date
    06-20-2012
    Location
    Neverland
    MS-Off Ver
    Excel 2007
    Posts
    8

    How to find all unique, matching values betwen two arrays of cells

    I really need help!

    I currently have a spreadsheet that is laid out with two blocks of text like so:

    Brick Bat Bear Pen Compass
    Red Blue Yellow Fish Hen
    Pig Pig Bear Fish Brick
    Compass Bat Pen Fish Brick


    Horse Bear Red Blue Dog

    I want to find the number of UNIQUE values in the first, big block of text that MATCH with the second small block of text. That is to say, if for instance "Red" matches with the block above 2 times, I want it to count once. If "Horse" matches 0 times, I want it to count as zero.

    I've tried everything! How would I set this function up?

  2. #2
    Forum Guru
    Join Date
    08-05-2004
    Location
    NJ
    MS-Off Ver
    365
    Posts
    13,582

    Re: How to find all unique, matching values betwen two arrays of cells

    Let's say your original block is in A1:E4 and your second block is in row 7

    Directly under Horse (in A8)
    =COUNTIF($A$1:$E$4,A7) dragged/copied to the right.

    Is that what you are looking for?
    ChemistB
    My 2?

    substitute commas with semi-colons if your region settings requires
    Don't forget to mark threads as "Solved" (Edit First post>Advanced>Change Prefix)
    If I helped, Don't forget to add to my reputation (click on the little star at bottom of this post)

    Forum Rules: How to use code tags, mark a thread solved, and keep yourself out of trouble

  3. #3
    Registered User
    Join Date
    06-20-2012
    Location
    Neverland
    MS-Off Ver
    Excel 2007
    Posts
    8

    Re: How to find all unique, matching values betwen two arrays of cells

    Thanks for the reply Chemist, but no, this wouldn't help.

    I want the COUNTIF to count ANY of the terms in the second block. (i.e. it would scan the top block for any of Horse Bear Red Blue Dog, and provide the count of the matching values)

    Second, I want it to only count a matching value ONCE. For example, "Bear" appears on the top block twice, but I only want it to count ONCE if it matches. In other words, I only want unique matching values.

    Does that make sense?

  4. #4
    Forum Guru
    Join Date
    08-05-2004
    Location
    NJ
    MS-Off Ver
    365
    Posts
    13,582

    Re: How to find all unique, matching values betwen two arrays of cells

    Sounds like you want to know if a word in the bottom block appears in the top block. If so, 1, if not, 0

    Try
    =IF(COUNTIF($A$1:$E$4,A7)>0,1,0)
    Is that what you are looking for?

  5. #5
    Registered User
    Join Date
    06-20-2012
    Location
    Neverland
    MS-Off Ver
    Excel 2007
    Posts
    8

    Re: How to find all unique, matching values betwen two arrays of cells

    Yes! This is actually perfect.

    However, I want run a count if using ALL the words in the bottom block at once. Is there anyway I can apply this formula, to search for all the words in the bottom block at one time?

  6. #6
    Forum Guru
    Join Date
    08-05-2004
    Location
    NJ
    MS-Off Ver
    365
    Posts
    13,582

    Re: How to find all unique, matching values betwen two arrays of cells

    This is the shortest I could come up with this late in the day

    =--(COUNTIF($A$1:$E$4,A7)>0) +-- (COUNTIF($A$1:$E$4,B7)>0) +--(COUNTIF($A$1:$E$4,C7)>0) +--(COUNTIF($A$1:$E$4,D7)>0)

  7. #7
    Forum Guru
    Join Date
    08-05-2004
    Location
    NJ
    MS-Off Ver
    365
    Posts
    13,582

    Re: How to find all unique, matching values betwen two arrays of cells

    Array formula (use CNTRL SHFT ENTER instead of Enter. You'll see brackets appear around the formula{})

    =SUM(--(COUNTIF($A$1:$E$4,A7:E7)>0))

  8. #8
    Registered User
    Join Date
    06-20-2012
    Location
    Neverland
    MS-Off Ver
    Excel 2007
    Posts
    8

    Re: How to find all unique, matching values betwen two arrays of cells

    Ah yeah, I found that way too, but I was hoping for find a method without inputting every single cell.

    Thanks for the attempt Chemist.

    If anyone else has any ideas, I'd be happy to hear them

  9. #9
    Registered User
    Join Date
    06-20-2012
    Location
    Neverland
    MS-Off Ver
    Excel 2007
    Posts
    8

    Re: How to find all unique, matching values betwen two arrays of cells

    You're a genius man...

    Thank you so much

  10. #10
    Registered User
    Join Date
    06-20-2012
    Location
    Neverland
    MS-Off Ver
    Excel 2007
    Posts
    8

    Re: How to find all unique, matching values betwen two arrays of cells

    out of curiosity, what do the two little dashes in the parentheses before COUNTIF do?

  11. #11
    Forum Guru
    Join Date
    08-05-2004
    Location
    NJ
    MS-Off Ver
    365
    Posts
    13,582

    Re: How to find all unique, matching values betwen two arrays of cells

    They change TRUE/FALSE Values into 1/0 values

  12. #12
    Forum Expert icestationzbra's Avatar
    Join Date
    01-07-2004
    MS-Off Ver
    2007, 2010
    Posts
    1,421

    Re: How to find all unique, matching values betwen two arrays of cells

    this non-CSE formula will do the same:

    =sumproduct(--($A$1:$E$4=A7:E7))

    however, there is a difference in the result of this formula versus @chemistb's if you have duplicates within each block. this sumproduct formula will *not* double-count duplicates within each block; it will only count duplicates across blocks.
    Last edited by icestationzbra; 06-20-2012 at 07:44 PM.
    - i.s.z -
    CSE, aka Array aka { }, formulae are confirmed with CONTROL+SHIFT+ENTER.
    Replace commas ( , ) with semicolons ( ; ) in formulae, if your locale setting demands.
    All good ideas are courtesy resources from this forum as well as others around the web.
    - e.o.m -

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1