Lookup on multi value cell in Excel
Lookup on multi value cell in Excel
Author
Discussion

anxious_ant

Original Poster:

2,626 posts

109 months

Thursday 29th October 2020
quotequote all
Hi all, would appreciate some thoughts on this.
I have an Excel spreadsheet and I need to lookup a value cells with multi comma separated values.
Note that some of the values are over 256 characters.

I've tried Vlookup but it only works for cells where the length is less that 256 characters.
Below is sample data. Say I want to lookup value "999"

My VLOOKUP formula is :

 =VLOOKUP("*"& 999 & "*", A1:B2,2,false) 


and it's expected to return "DEF".

This doesn't work if values in A is more than 256 characters. I've had a look at suggestions using INDEX and MATCH but that doesn't seem to work.

A B
123,3434,52525 ABC
99494,9349,98983,999 DEF

B9

534 posts

125 months

Thursday 29th October 2020
quotequote all
anxious_ant said:
Hi all, would appreciate some thoughts on this.
I have an Excel spreadsheet and I need to lookup a value cells with multi comma separated values.
Note that some of the values are over 256 characters.

I've tried Vlookup but it only works for cells where the length is less that 256 characters.
Below is sample data. Say I want to lookup value "999"

My VLOOKUP formula is :

 =VLOOKUP("*"& 999 & "*", A1:B2,2,false) 


and it's expected to return "DEF".

This doesn't work if values in A is more than 256 characters. I've had a look at suggestions using INDEX and MATCH but that doesn't seem to work.

AB
123,3434,52525ABC
99494,9349,98983,999DEF
Could you utilise the find formula? So put this in column C against each record

=IF(IFERROR(FIND("999",A2,1),"No Match")="No Match", "No Match",B2)

ABC
123,3434,52525ABCNo Match
99494,9349,98983,999DEFDEF

mmm-five

12,392 posts

314 months

Thursday 29th October 2020
quotequote all
As far as I know the max length is 255 for Find/Match/Lookup.

My simple solution (which may not work for you) was to create another column to trim the data to 200 characters, as I worked out that was how many I'd need to result in unique strings...but I only had 17,000 entries to go through.

Luke-36

69 posts

134 months

Thursday 29th October 2020
quotequote all
I'm not totally sure how to paste tables/ code etc correctly in this forum, but the way i'd achieve what you're trying to do is:

have a value to find cell. in my case it's cell C1, and in that cell is 494
Then, enter a blank column to the left of your data. in my case it's column A
In column A put this formula in:
=IFERROR(IF(SEARCH($C$1,B4)>=1,$C$1,0),0) --> i.e. seach each cell for the number you've put in cell C1... once you've found that number, return it.

Then, it's a simple vlookup. In my case this is in cell D1
=VLOOKUP(C1,$A$3:$C$5,3,0)

Not sure if this achieves what you are after.


sideways sid

1,467 posts

245 months

Thursday 29th October 2020
quotequote all
Assuming none of the cells exceeds 510 characters, this should work:

=IFERROR(IF(OR(FIND("999",RIGHT(A1,256),1)>0,FIND("999",LEFT(A1,256),1)>0),"DEF","No Match"),"No Match")

anxious_ant

Original Poster:

2,626 posts

109 months

Thursday 29th October 2020
quotequote all
Wow, many helpful replies here thank you all! Sorry I don't think I've mastered the art of multi quoting yet...

I will have a look at the suggestions and see where I get to. Might have to import data into SQL for manipulation. Shame about the 256 character limit in Excel.

anxious_ant

Original Poster:

2,626 posts

109 months

Thursday 29th October 2020
quotequote all
sideways sid said:
Assuming none of the cells exceeds 510 characters, this should work:

=IFERROR(IF(OR(FIND("999",RIGHT(A1,256),1)>0,FIND("999",LEFT(A1,256),1)>0),"DEF","No Match"),"No Match")
Unfortunately some cells have 700+ characters frown

anxious_ant

Original Poster:

2,626 posts

109 months

Thursday 29th October 2020
quotequote all
Luke-36 said:
I'm not totally sure how to paste tables/ code etc correctly in this forum, but the way i'd achieve what you're trying to do is:

have a value to find cell. in my case it's cell C1, and in that cell is 494
Then, enter a blank column to the left of your data. in my case it's column A
In column A put this formula in:
=IFERROR(IF(SEARCH($C$1,B4)>=1,$C$1,0),0) --> i.e. seach each cell for the number you've put in cell C1... once you've found that number, return it.

Then, it's a simple vlookup. In my case this is in cell D1
=VLOOKUP(C1,$A$3:$C$5,3,0)

Not sure if this achieves what you are after.

Interesting, I will have a look at the SEARCH function. Unfortunately it's not just a single cell that will be used for the search, I have another list of values to search through.

paulrockliffe

16,621 posts

257 months

Friday 30th October 2020
quotequote all
anxious_ant said:
Wow, many helpful replies here thank you all! Sorry I don't think I've mastered the art of multi quoting yet...

I will have a look at the suggestions and see where I get to. Might have to import data into SQL for manipulation. Shame about the 256 character limit in Excel.
Generally if you need to use a VLOOKUP I would drop the tables into PowerPivot, setup a relationship between the two tables and sack off formulas completely.

If you're talking about using SQL to manipulate the data to get this to work, load it into PowerQuery to do that bit, then load the result into PowerPivot, setup a relationship and get your output into a Pivot Table.

The 256 character limit is a Cell limit, not an Excel limit, PowerQuery will deal with it fine as it's not loading into a Cell. I think anyway, not sure if I've ever had to test that.

anxious_ant

Original Poster:

2,626 posts

109 months

Friday 30th October 2020
quotequote all
paulrockliffe said:
anxious_ant said:
Wow, many helpful replies here thank you all! Sorry I don't think I've mastered the art of multi quoting yet...

I will have a look at the suggestions and see where I get to. Might have to import data into SQL for manipulation. Shame about the 256 character limit in Excel.
Generally if you need to use a VLOOKUP I would drop the tables into PowerPivot, setup a relationship between the two tables and sack off formulas completely.

If you're talking about using SQL to manipulate the data to get this to work, load it into PowerQuery to do that bit, then load the result into PowerPivot, setup a relationship and get your output into a Pivot Table.

The 256 character limit is a Cell limit, not an Excel limit, PowerQuery will deal with it fine as it's not loading into a Cell. I think anyway, not sure if I've ever had to test that.
Thanks Paul, this is indeed very helpful information. I've not used PowerQuery much but I have written a few Power BI reports, so I'm guessing it's similiar? (DAX)