+ Reply to Thread
Results 1 to 8 of 8

how to xlookup if the search keys are comma-separated.

  1. #1
    Registered User
    Join Date
    11-27-2021
    Location
    Lagos
    MS-Off Ver
    365
    Posts
    4

    how to xlookup if the search keys are comma-separated.

    Hello,
    I have an excel sheet attached. I am trying to xlookup some search keys are comma-separated in excel.
    What I would like to do is to SUM up all the returned values into a single cell. I dont know if this is possible for I have to use some VBA scripts.

    I tried =XLOOKUP(F2,$A$1:$A$14,$B$1:$B$14)

    Any ideas would be greatly appreciated.

    a.JPG
    Attached Files Attached Files

  2. #2
    Forum Expert
    Join Date
    09-07-2014
    Location
    Israel
    MS-Off Ver
    office 365 for MAC
    Posts
    3,105

    Re: how to xlookup if the search keys are comma-separated.

    hi,
    you may have more than 2 items in one cell?

  3. #3
    Registered User
    Join Date
    11-27-2021
    Location
    Lagos
    MS-Off Ver
    365
    Posts
    4

    Re: how to xlookup if the search keys are comma-separated.

    . .
    Last edited by tubony; 11-27-2021 at 02:23 PM.

  4. #4
    Registered User
    Join Date
    11-27-2021
    Location
    Lagos
    MS-Off Ver
    365
    Posts
    4

    Re: how to xlookup if the search keys are comma-separated.

    Quote Originally Posted by belinda200 View Post
    hi,
    you may have more than 2 items in one cell?
    Yes please. If possible I would want to sum the returned values into a single cell.

  5. #5
    Forum Expert
    Join Date
    09-07-2014
    Location
    Israel
    MS-Off Ver
    office 365 for MAC
    Posts
    3,105

    Re: how to xlookup if the search keys are comma-separated.

    try this for 2 values in a cell:
    =IFERROR(XLOOKUP(LEFT(F2,SEARCH(",",F2)-1),$A$2:$A$11,$B$2:$B$11)+XLOOKUP(MID(F2,SEARCH(",",F2)+1,99),$A$2:$A$11,$B$2:$B$11),XLOOKUP(F2,$A$2:$A$11,$B$2:$B$11))
    Attached Files Attached Files

  6. #6
    Forum Guru Bo_Ry's Avatar
    Join Date
    09-10-2018
    Location
    Thailand
    MS-Off Ver
    MS 365
    Posts
    7,211

    Re: how to xlookup if the search keys are comma-separated.

    Please try

    =SUM(XLOOKUP(FILTERXML("<x><m>"&SUBSTITUTE(F2,",","</m><m>")&"</m></x>","//m"),$A$2:$A$14,$B$2:$B$14,0))

    or
    =MMULT(SUMIFS($B$2:$B$15,$A$2:$A$15,TRIM(MID(SUBSTITUTE(F2:F5,",",REPT(" ",99)),SEQUENCE(,9,,99),99))),SEQUENCE(9,,,0))
    Attached Files Attached Files

  7. #7
    Registered User
    Join Date
    11-27-2021
    Location
    Lagos
    MS-Off Ver
    365
    Posts
    4

    Re: how to xlookup if the search keys are comma-separated.

    Quote Originally Posted by belinda200 View Post
    try this for 2 values in a cell:
    =IFERROR(XLOOKUP(LEFT(F2,SEARCH(",",F2)-1),$A$2:$A$11,$B$2:$B$11)+XLOOKUP(MID(F2,SEARCH(",",F2)+1,99),$A$2:$A$11,$B$2:$B$11),XLOOKUP(F2,$A$2:$A$11,$B$2:$B$11))
    Thanks this worked. But it does not cater for duplicate values. for example, if I have duplicate product id: MK003 in the column it does not sum them.
    Also it does not work if the comma separated values are more than two.

  8. #8
    Forum Expert wk9128's Avatar
    Join Date
    08-15-2020
    Location
    Australia
    MS-Off Ver
    365 V2403 and WPS V2022
    Posts
    3,427

    Re: how to xlookup if the search keys are comma-separated.

    No need for XLOOKUP

    Cell G2 formula , Drag down

    Formula: copy to clipboard
    Please Login or Register  to view this content.

+ 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. [SOLVED] XLOOKUP when the lookup value has comma separated cell
    By Eades1412 in forum Excel Formulas & Functions
    Replies: 12
    Last Post: 03-06-2024, 11:43 AM
  2. Replies: 4
    Last Post: 12-01-2020, 01:20 PM
  3. Replies: 2
    Last Post: 07-26-2019, 12:11 AM
  4. [SOLVED] Vlookup or Index to search and return multiple values in one cell separated by a comma
    By Trnecessary in forum Excel Formulas & Functions
    Replies: 18
    Last Post: 10-17-2018, 12:59 PM
  5. search and delete multiple item separated by a comma
    By BORUCH in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 01-15-2018, 02:12 AM
  6. Vlookup multiple comma seperated search keys
    By Achiles625 in forum Excel Formulas & Functions
    Replies: 6
    Last Post: 02-20-2015, 07:00 PM
  7. Search for comma-separated list of items
    By BBerndsen in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 03-15-2013, 11:16 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