+ Reply to Thread
Results 1 to 19 of 19

Vlookup or Index to search and return multiple values in one cell separated by a comma

  1. #1
    Registered User
    Join Date
    09-05-2018
    Location
    Indiana
    MS-Off Ver
    Office 2013
    Posts
    14

    Vlookup or Index to search and return multiple values in one cell separated by a comma

    I am trying to search in column A and return what is in column B. My lookup value is in column D and then my table is A&B. For some reason, the vlookup formula isn't working correctly. Maybe vlookup isn't what I need. I need column D to search within column A and return multiple values from Column B separated with a column.


    Correction, it might need to be titled Search for text string in a cell and return adjacent values in the same cell separated by a coma.
    Attached Files Attached Files
    Last edited by Trnecessary; 10-17-2018 at 10:02 AM. Reason: update

  2. #2
    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
    43,986

    Re: Vlookup or Index to search and return multiple values in one cell separated by a comma

    Your "sample" file was a tad large!! If you REALLY want all these in one cell for each row's resuts you will need VBA. This returns one value per cell. I have not processed all the rows as my crappy laptop isn't up to it. But, in principle: drag across and down as far as needed.

    =IFERROR(INDEX($B:$B,AGGREGATE(15,6,ROW($A$1:$A$5850)/(ISNUMBER(SEARCH($C1,$A$1:$A$5850))),COLUMNS($A:A))),"")
    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

  3. #3
    Registered User
    Join Date
    09-05-2018
    Location
    Indiana
    MS-Off Ver
    Office 2013
    Posts
    14

    Re: Vlookup or Index to search and return multiple values in one cell separated by a comma

    Thanks Glenn, I had posted this in the VBA section as well because I didn't know about the size and the amount of work it would need.

  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
    43,986

    Re: Vlookup or Index to search and return multiple values in one cell separated by a comma

    Naughty you. Double posting is against the rules. It can lead to time wasting and anmoyance. Is my offering of any use to you?

  5. #5
    Registered User
    Join Date
    09-05-2018
    Location
    Indiana
    MS-Off Ver
    Office 2013
    Posts
    14

    Re: Vlookup or Index to search and return multiple values in one cell separated by a comma

    I tried that formula and it didn't really work but I am open to suggestions on how to get this piece done. Its the only thing hindering me from going forward. I can do a test search and just ctrl+F and take a value from column D and search in column A. Then look to the adjaced cell and just copy and paste. I could do this manually but it would save hours of work for me.

  6. #6
    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
    43,986

    Re: Vlookup or Index to search and return multiple values in one cell separated by a comma

    What do you mean by "it didn't really work"? What was arong? Where was it wrong?

  7. #7
    Registered User
    Join Date
    09-05-2018
    Location
    Indiana
    MS-Off Ver
    Office 2013
    Posts
    14

    Re: Vlookup or Index to search and return multiple values in one cell separated by a comma

    I copied that formula and pasted it in Cell C2. It only returned one value (which you had previously stated it would do) and that value was incorrect. Am I doing something incorrectly with the formula?

  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
    43,986

    Re: Vlookup or Index to search and return multiple values in one cell separated by a comma

    Did I misread your requirement?

    I searched in column A for all cases where the value in C1 was present. the formula then returned the corresponding values from column B, one number per cell going across. if that's not what you wanted, please explain in the same terms to those I have used, what you DO want.

  9. #9
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2404 (Windows 11 22H2 64-bit)
    Posts
    80,460

    Re: Vlookup or Index to search and return multiple values in one cell separated by a comma

    Duplicate threads are not allowed, so please do not open anymore on the same issue. Your other thread has now been closed. Thank you.
    Ali


    Enthusiastic self-taught user of MS Excel who's always learning!
    Don't forget to say "thank you" in your thread to anyone who has offered you help.
    You can reward them by clicking on * Add Reputation below their user name on the left, if you wish.

    Forum Rules (updated August 2023): please read them here.

  10. #10
    Registered User
    Join Date
    09-05-2018
    Location
    Indiana
    MS-Off Ver
    Office 2013
    Posts
    14

    Re: Vlookup or Index to search and return multiple values in one cell separated by a comma

    Sorry about that Glenn, that was my fault in not explaining what I wanted.

    Search in column A for all cases that has the text string from C2. It should return values (multiple if found other times) in the same cell. If possible, I was going to drag this down to continue searching for the adjacent cell and populate the ID numbers associated with them.

    Does that make sense or am I just spinning in circles?

    Thanks Glenn

  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
    43,986

    Re: Vlookup or Index to search and return multiple values in one cell separated by a comma

    STILL not clear. "It should return values"... WHAT values?

  12. #12
    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
    43,986

    Re: Vlookup or Index to search and return multiple values in one cell separated by a comma

    Also bear in mind that the data in your sample sheety started in ROW 1 not row 2.

  13. #13
    Registered User
    Join Date
    09-05-2018
    Location
    Indiana
    MS-Off Ver
    Office 2013
    Posts
    14

    Re: Vlookup or Index to search and return multiple values in one cell separated by a comma

    It should return the ID's adjacent to the cell that its found in column A. So if I were to search for NEPHROLITHOTOMY PERCUTANEOUS, it would find that text string in cell A3988 and A3989 and then it would return value in Column B Cell B3988 and B3989.

    B3988 value is 10700003987
    B3989 value is 10700003988

    Those two values would populate in one cell basically.

  14. #14
    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
    43,986

    Re: Vlookup or Index to search and return multiple values in one cell separated by a comma

    And my formula did that, albeit in different cells. Look at D1 and E1 in the sheet from Post 2. I suspect the sheet that you posted and the sheet you are working with DIFFER in that yours has a header row, while the posted one has none.

    I will post a UDF shortly to do exactly the same, will all numbers in one cell.

  15. #15
    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
    43,986

    Re: Vlookup or Index to search and return multiple values in one cell separated by a comma

    Firstly, my sheet from Post 2.... again... showing that it did return the expected result.
    Attached Files Attached Files

  16. #16
    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
    43,986

    Re: Vlookup or Index to search and return multiple values in one cell separated by a comma

    Secondly a UDF. I will explain it, ONCE you agree that it is doing what you want IN TJIS SHEET. Enable macros on opening.

    The UDF is an array formula. These need to be set with CTRL-SHIFT & ENTER and not just Enter.
    Attached Files Attached Files

  17. #17
    Registered User
    Join Date
    09-05-2018
    Location
    Indiana
    MS-Off Ver
    Office 2013
    Posts
    14

    Re: Vlookup or Index to search and return multiple values in one cell separated by a comma

    GLENN!!! YOU BEAUTIFUL, SMART MAN!!!! You are an EXCEL Genius! Seriously, I can't thank you enough. Sorry again for posting in two areas. I just didn't know which one it would be, formula or VBA.

  18. #18
    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
    43,986

    Re: Vlookup or Index to search and return multiple values in one cell separated by a comma

    Even she-who-must-be-obeyed has never called me beautiful!!

    Aww gee shucks...

    You're welcome.



    If that takes care of your original question, please select "Thread Tools" from the menu link above and mark this thread as SOLVED.

    It'd also be appreciated if you were to click the Add Reputation button at the foot of any of the posts of all members who helped you reach a solution.

  19. #19
    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
    43,986

    Re: Vlookup or Index to search and return multiple values in one cell separated by a comma

    Incidentally, if you went for the UDF, do you know what to do to implement it in your own sheet?

+ 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] Sum values using vlookup with lookup cell containing comma separated values
    By tmalito in forum Excel Formulas & Functions
    Replies: 10
    Last Post: 09-08-2019, 10:14 AM
  2. Vlookup or Index to search and return multiple values in one cell separated by a comma
    By Trnecessary in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 10-17-2018, 10:37 AM
  3. [SOLVED] Return multiple matchng VLOOKUP values in one cell separated by commas?
    By zendoo in forum Excel Formulas & Functions
    Replies: 9
    Last Post: 12-14-2015, 06:10 AM
  4. Replies: 4
    Last Post: 11-16-2015, 05:12 AM
  5. INDEX & MATCH multiple rows to return comma separated cell
    By sifuchi in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 02-18-2015, 04:36 PM
  6. Search cell for multiple text , return comma separated text in separate cell if found
    By dangerdoug in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 10-01-2013, 01:52 PM
  7. Return Y/N after matching from multiple lookup values separated by comma
    By indoglans in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 03-16-2011, 03:13 PM

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