Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
1.5k views
in Technique[技术] by (71.8m points)

excel - If string contains word from list, return value adjacent to list value

Currently I have a set of cells, and each has, among useless information, a unique identifier. I also have a list of these unique identifiers, as well as what value each identifier corresponds to.

What I would like to do is find which, if any, identifier a cell contains, and then output the corresponding value, below is an example:

http://i.stack.imgur.com/97aKI.png

So where the cell contains "ADC", I would like excel to find where ADC comes up in the reference array, and then return the corresponding value.

If this can be done with a formula or a macro, either would be great. I have tried fiddling with index, match, and search, in various combinations, but nothing seems to be working. I have found creating a massive if statement to be impractical as there are about 70 unique values to search for.

Any suggestions would be welcome!

edit: I was recommended to use vlookup, but I am not looking for an identical match, but instead for a specific value contained within a string. If vlookup does have this functionality then could somebody show me how to put this into practice with my specific example?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

One method of a 'reverse-wildcard' lookup can be achieved is with the newer AGGREGATE1 function. This function can produce cyclic calculation and has an option (e.g. 6) to discard errors. Use this to produce a row number on the match to the cross-reference table with the INDEX function returning the actual value.

??????Reverse VLOOKUP

The formula in B3 is,

=INDEX(F$3:F$5, AGGREGATE(15, 6, ROW($1:$3)*SIGN(MATCH("*"&E$3:E$5&"*", A3, 0)), 1))

Note that ROW(1:3) is the position within F3:F5, not the actual row number on the worksheet. I've also scrambled the Find and Insert values in your original cross-reference table to avoid the perception of an associative lookup match.


1 The AGGREGATE function was introduced with Excel 2010. It is not available in earlier versions.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...