Assuming I want to create a lookup function that searches certain string, let's says "dog;cat" and I want it to go through a certain array, and return column b in that array in the row that partially matches that string, for example:
Horse 5
Cat 2
Wolf 3
So in this example I'd expect to get "2". Is it possible? Searched the net for answers, but couldn't find anything helpful. Please note the string I'm searching can be complex, for example - "dog;shark;cat;pigeon"... So it has to be a universal solution.
Any help will be appreciated :)
With data like:
Put the "long string" in say D1 and in E1 enter:
Notes:
Usually we use SEARCH() or FIND() or MATCH() to see if a big string contains a little string....................in this case we want to find which little string is in the big string !
This will work if you're always returning a single numerical value:
For your example data, search_range is the range holding
Horse, Cat, Wolf
; search_for holds "dog;cat"; and values_range is the range holding5, 2, 3
.Hope that helps
You could split your array to list each variable in a separate row then use a VLOOKUP function to compare each value to your table. (The table would have to be sorted into alphabetical order first.)
Extending your example, if you split the array into column C, you could use the following fomula in the first row of column D:
Using the absolute reference to the lookup table will allow you to copy the formula into additional rows. The result for your suggested values will be:
Try this UDF out.
SearchFor is what you want to find. This is a delimited text string, for example "cat;dog;horse".
SearchIn is the cell range you want to look in.
The last parameter is the delimiter that will split the SearchFor variable. In the example above "cat;dog;horse" the delimiter would be ";".