[英]Lookup a value from a cell with multiple values
I have an excel file containing 2 columns (Area Code) & (State). 我有一个包含2列(区号)和(州)的Excel文件。
**Area Code** **State**
217, 224, 309, 312, 331, 618, 630, 708, 773, 779, 815, 847, 872 Illinois
219, 260, 317, 574, 765, 812 Indiana
319, 515, 563, 641, 712 Iowa
316, 620, 785, 913 Kansas
270, 502, 606, 859 Kentucky
I want to use vlookup() for a given area code like "620" and get "Kansas". 我想对给定的区号(如“ 620”)使用vlookup()并获取“堪萨斯州”。 please note that all the values in a row are stored in one cell (ie "270, 502, 606, 859" are stored in one cell)
请注意,一行中的所有值都存储在一个单元格中(即“ 270、502、606、859”存储在一个单元格中)
=VLookup("*620*", A2:B6, 2, false)
In VBA: 在VBA中:
Function FindState(code as integer) as string
FindState = Application.VLookup("*" & code & "*", mySheet.Range("A2:B6"), 2, false)
End sub
=VLOOKUP(INDEX(A:A,MATCH(TRUE,ISNUMBER(FIND(d2,A:A,1)),0)),A:B,2,0)
Assuming the number you want to find is in d2 and the data is stored in columns a and b. 假设您要查找的数字在d2中,并且数据存储在a和b列中。
I asked to find the first find without and error and return the row number. 我要求找到没有和错误的第一个发现并返回行号。 After that, I a lookup for it.
之后,我要查找它。
Use array formula ctrl+shift+enter 使用数组公式Ctrl + Shift + Enter
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.