Chintan Zaveri
Chintan Zaveri

Reputation: 1

Check each comma-separated value in a cell if it matches a certain number

In Google Sheets:

I have 2 sheets, "Sheet A" and "Sheet B".

"Sheet A" has two columns, Column A, whose cells contain comma-separated values like the following:

AND Column B, whose cells have names, like:

"Sheet B", Column A has values like:

Within "Sheet B", Column B: I need to fetch the value contained in the "Sheet A", corresponding cell in Column B if it matches with "Sheet B", Column A:

So, based upon the above hypothetical values, it would be as follows: (in Sheet B, Column B)

Any idea how I can do this? If it were not for the comma-separated values, I would have used VLOOKUP directly. I am sure there would be some simple way to do this. Looking forward to your help.

Thanks and regards,

Chintan.

P.S. Sorry for the terrible formatting of this question. Promise to do better on my next one once I learn more about formatting on stackoverflow.

Upvotes: 0

Views: 797

Answers (1)

JPV
JPV

Reputation: 27242

See if this works ?

=iferror(ArrayFormula(vlookup(A2:A, {transpose(split(substitute(query(Sheet1!A2:A,,rows(Sheet1!A2:A)), " ", ","),",")), transpose(split(query(rept(Sheet1!B2:B&" ", if(len(Sheet1!A2:A), len(Sheet1!A2:A)-len(substitute(Sheet1!A2:A, ",",""))+1,0)),,50000)," "))}, 2, 0)))

Change sheet names and ranges to suit.

Screenshot

Example spreadsheet

Upvotes: 2

Related Questions