简体   繁体   中英

Excel - VLOOKUP return based on partial string

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.

在此处输入图片说明

试试这个...将帮助您

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

Use:

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

Results:

在此处输入图片说明

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM