简体   繁体   English

从具有多个值的单元格中查找一个值

[英]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.

相关问题 从具有多个值 excel 的单元格中查找值 - Lookup value from a cell which has multiple values excel 如果查找值在单个单元格中包含多个值,则如何使用vlookup - How to use vlookup if lookup value contains multiple values in single cell 单元格查找的多次返回 - Multiple returns from a cell lookup Excel VBA中的自定义函数,该函数在返回多个匹配值并将其组合到一个单元格的范围内查找单元格值 - Custom function in excel vba that lookup a cell value in a range that returns multiple match values and combine them in one cell 使用excel VBA查找单元格值,并基于该单元格返回多个值 - Using excel VBA to lookup cell value, and return multiple values based on that cell 在一个单元格中列出的值中查找值并显示其他单元格中列出的值的结果 - Lookup value in values listed within one cell and show result from listed values within other cell 查找并将唯一的多个值连接到一个单元格中 - Lookup and concatenate unique multiple values into one cell Excel - 多个值,需要从查找中添加值 - Excel - Multiple values and need to add value from lookup 根据具有多个查找值的查找值从范围中获取标头值 - Get header value from range based on lookup value with multiple lookup values 如果值存在,如何跨多个表查找值并进行单元格更新? - How to Lookup values across multiple tables and make a cell update if value present?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM