Excel - VLOOKUP return based on partial string

谁说我不能喝 提交于 2021-01-28 11:14:13

问题


I am trying to get VLOOKUP to return a value based on a partial string. So I want to say: look up this string, look in the list and if you find a partial string matching it, return the date next to it. But not having much luck. In my example, B2 should show: April 9th as the first bit of the string in D2 matches.


回答1:


Use:

=VLOOKUP(MID(A2,1,FIND(" ",A2,FIND(" ",A2)+1)-1),$D$2:$E$4,2,FALSE)

Results:




回答2:


Try this one... Will help you

=VLOOKUP(LEFT(A3,FIND(" ",A3,FIND(" ",A3)+1)-1),$D$3:$E$5,2,0)



回答3:


Or you can do the other way around and use combination of INDEX and MATCH (with wildcard match) - look at the picture:

=INDEX($D$1:$E$4,MATCH(D2&"*",$A$2:$A$4,0)+1,2)

INDEX MATCH example

Advantage is of this is that you do not assume a given pattern of your values. So it does not matter whether it is SPXL APR19 59P or SPXL APR19_____59P.

You can also use the asterisk on both sides "*"&[]&"*", so then you'll do an inside search.



来源:https://stackoverflow.com/questions/54663802/excel-vlookup-return-based-on-partial-string

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!