+ Reply to Thread
Results 1 to 13 of 13

Checking to see if multiple values from one list exist in the other

  1. #1
    Forum Contributor
    Join Date
    07-25-2017
    Location
    UK
    MS-Off Ver
    Office 365 Excel Version 2202 Build 16
    Posts
    184

    Checking to see if multiple values from one list exist in the other

    Hi,

    In the attached spreadsheet, I require a formula which checks if any of the product names in sheet2 column A exist in sheet1 column A and if there is a match to include the word Yes in column b of sheet 1.

    All product names are text only. In Sheet 1 Column A there are some cells which contain multiple product names. I would like the formula to be able to check these cells too so that if the cell contains a product from Sheet 2 Column A, then to mark it as a match.

    Thank you in advance.
    Attached Files Attached Files

  2. #2
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,447

    Re: Checking to see if multiple values from one list exist in the other

    How is this different to the last time you asked this question?

    https://www.excelforum.com/excel-for...ml#post5633802
    Trevor Shuttleworth - Retired Excel/VBA Consultant

    I dream of a better world where chickens can cross the road without having their motives questioned

    'Being unapologetic means never having to say you're sorry' John Cooper Clarke


  3. #3
    Forum Expert
    Join Date
    07-20-2011
    Location
    Mysore, India.
    MS-Off Ver
    Excel 2019
    Posts
    8,587

    Re: Checking to see if multiple values from one list exist in the other

    Try any one

    =COUNTIF(Sheet2!$A$1:$A$9,A2)>0

    Or

    =ISNUMBER(MATCH(A2,Sheet2!$A$1:$A$9,0))
    Attached Files Attached Files
    Pl note
    Array formula should be confirmed with Ctrl+Shift+Enter keys together.
    If answere is satisfactory press * to add reputation.

  4. #4
    Forum Moderator Glenn Kennedy's Avatar
    Join Date
    07-08-2012
    Location
    Digital Nomad... occasionally based in Ireland.
    MS-Off Ver
    O365 (PC) V 2403
    Posts
    44,053

    Re: Checking to see if multiple values from one list exist in the other

    The tricky one was sweet potato... ensuring it wasn't recorded as a match wit potato.

    =IF(SUMPRODUCT(IFERROR(MATCH((FILTERXML("<A><B>"&SUBSTITUTE(A2,",","</B><B>")&"</B></A>","//B")),Sheet2!$A$1:$A$9,0),""))>0,"Match","")
    Attached Files Attached Files
    Glenn




    None of us get paid for helping you... we do this for fun. So DON'T FORGET to say "Thank You" to all who have freely given some of their time to help YOU.

    Temporary addition of accented to illustrate ongoing problem to the TT: L? fh?ile P?draig sona dhaoibh

  5. #5
    Forum Contributor
    Join Date
    07-25-2017
    Location
    UK
    MS-Off Ver
    Office 365 Excel Version 2202 Build 16
    Posts
    184

    Re: Checking to see if multiple values from one list exist in the other

    Quote Originally Posted by kvsrinivasamurthy View Post
    Try any one

    =COUNTIF(Sheet2!$A$1:$A$9,A2)>0

    Or

    =ISNUMBER(MATCH(A2,Sheet2!$A$1:$A$9,0))



    Thank you kvsrinivasamurthy, The formulas handle part of the problem however there are a few cells in sheet 1 column which contain multiple product names, which the formula is returning as false however I need the formula to produce a value of true even if there is one product that matches from sheet2.

    Example 1 : we know apples are in list sheet 2. There is a cell in sheet 1 which contains the text "potato, apples, pears". All these items appear in the sheet2 therefore I need the formula to return 'True'

    Example 2 : There is a cell in sheet 2 which contains the text "beetroot, apples, radish". The item apple appears in sheet 2 therefore I need the formula to return 'True'

    Also it is worth mentioning that a comma will not always appear after product for the cells that contain multiple product names.

    I have re-attached the spreadsheet with the cells in question.
    Attached Files Attached Files

  6. #6
    Forum Contributor
    Join Date
    07-25-2017
    Location
    UK
    MS-Off Ver
    Office 365 Excel Version 2202 Build 16
    Posts
    184

    Re: Checking to see if multiple values from one list exist in the other

    Quote Originally Posted by Glenn Kennedy View Post
    The tricky one was sweet potato... ensuring it wasn't recorded as a match wit potato.

    =IF(SUMPRODUCT(IFERROR(MATCH((FILTERXML("<A><B>"&SUBSTITUTE(A2,",","</B><B>")&"</B></A>","//B")),Sheet2!$A$1:$A$9,0),""))>0,"Match","")

    Thank you very much Glen. You are on the right lines. I appreciate the point about the sweet potato however for the purpose of the sanity check I will be doing we can record sweet potato as a match.

    There is an issue which I overlooked. Not all the cells containing multiple products will be separated by a comma. I've included a revised spreadsheet in my post above.

  7. #7
    Forum Moderator Glenn Kennedy's Avatar
    Join Date
    07-08-2012
    Location
    Digital Nomad... occasionally based in Ireland.
    MS-Off Ver
    O365 (PC) V 2403
    Posts
    44,053

    Re: Checking to see if multiple values from one list exist in the other

    So we now have not just a , but also:

    feat.
    and
    &


    What other delimiters can there be?
    Last edited by Glenn Kennedy; 02-14-2022 at 09:57 AM.

  8. #8
    Forum Moderator Glenn Kennedy's Avatar
    Join Date
    07-08-2012
    Location
    Digital Nomad... occasionally based in Ireland.
    MS-Off Ver
    O365 (PC) V 2403
    Posts
    44,053

    Re: Checking to see if multiple values from one list exist in the other

    See file. Please note that I HAD solved the sweet potato issue in my last post. It is correctly identified as NOT being a match for potato.

    =IF(SUMPRODUCT(IFERROR(MATCH((FILTERXML("<A><B>"&SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(A2,"and",","),"&",","),"feat.",","),",","</B><B>")&"</B></A>","//B")),Sheet2!$A$1:$A$9,0),""))>0,"Match","")
    Attached Files Attached Files

  9. #9
    Forum Contributor
    Join Date
    07-25-2017
    Location
    UK
    MS-Off Ver
    Office 365 Excel Version 2202 Build 16
    Posts
    184

    Re: Checking to see if multiple values from one list exist in the other

    Quote Originally Posted by Glenn Kennedy View Post
    So we now have not just a , but also:

    feat.
    and
    &


    What other delimiters can there be?
    Looking at my source data here is what i found:

    feat.
    ft.
    &
    ,
    f/
    :

  10. #10
    Forum Moderator Glenn Kennedy's Avatar
    Join Date
    07-08-2012
    Location
    Digital Nomad... occasionally based in Ireland.
    MS-Off Ver
    O365 (PC) V 2403
    Posts
    44,053

    Re: Checking to see if multiple values from one list exist in the other

    OK. Sufficiently small in number to allow for a few more nested SUBSTITUTEs. Out for a walk. Back in an hour.

  11. #11
    Forum Moderator Glenn Kennedy's Avatar
    Join Date
    07-08-2012
    Location
    Digital Nomad... occasionally based in Ireland.
    MS-Off Ver
    O365 (PC) V 2403
    Posts
    44,053

    Re: Checking to see if multiple values from one list exist in the other

    Final version:

    =IF(SUMPRODUCT(IFERROR(MATCH((FILTERXML("<A><B>"&SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(A2,":",","),"f/",","),"ft.",","),"and",","),"&",","),"feat.",","),",","</B><B>")&"</B></A>","//B")),Sheet2!$A$1:$A$9,0),""))>0,"Match","")
    Attached Files Attached Files

  12. #12
    Forum Contributor
    Join Date
    07-25-2017
    Location
    UK
    MS-Off Ver
    Office 365 Excel Version 2202 Build 16
    Posts
    184

    Re: Checking to see if multiple values from one list exist in the other

    Glenn - you are a magician. Thank you so much.

    The spreadsheet I have consists of 162424 rows. The formula you designed has made dealing with updates to this spreadsheet very effective.

  13. #13
    Forum Moderator Glenn Kennedy's Avatar
    Join Date
    07-08-2012
    Location
    Digital Nomad... occasionally based in Ireland.
    MS-Off Ver
    O365 (PC) V 2403
    Posts
    44,053

    Re: Checking to see if multiple values from one list exist in the other

    You're welcome! Thanks for the feedback.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Checking for values if they exist in 2 tables and brings different values
    By Atlantian in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 10-06-2014, 01:27 PM
  2. Does list 2 values exist somewhere in the list 1 cell?
    By popskull in forum Excel Formulas & Functions
    Replies: 10
    Last Post: 12-18-2013, 07:36 AM
  3. [SOLVED] Checking if non-integer values exist in a range
    By davidman1 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 03-21-2013, 02:57 PM
  4. Checking if multiple sheets exist
    By bd528 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 06-23-2011, 07:11 AM
  5. List row numbers where cell values exist
    By maxald in forum Excel General
    Replies: 8
    Last Post: 06-07-2010, 07:45 AM
  6. checking if shapes exist and grouping them
    By gummi in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 11-21-2008, 11:12 AM
  7. Checking Files Exist
    By biggs in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 03-06-2008, 11:31 AM

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