简体   繁体   English

如何从 2 个查找值单元格中使用 vlookup

[英]how to use vlookup from 2 lookup value cell

i have a table of names with their numbers and want to use vlookup formula to lookup a specific number from a cell from that table and return me the name as the result but if the specific number in that cell is not found then i want it to try another cell for example我有一个带有数字的名称表,并想使用 vlookup 公式从该表的单元格中查找特定数字,并将名称作为结果返回给我,但如果未找到该单元格中的特定数字,那么我想要它例如尝试另一个单元格

Table has 2 column表有 2 列

Note employee code consist of 3 numbers and station number consist of 4 numbers注意员工代码由3个数字组成,站号由4个数字组成

| Employee Code/Station Number # |  Name  |
|:------------------------------:|:------:|
| 123                            |  John  |
| 456                            | joseph |
| 3213                           |  jack  |
| 5656                           |  John  |

On the next sheet for the result I have 3 columns在结果的下一张纸上,我有 3 列

| Employee Code | Employee Station No | Name |
|---------------|---------------------|------|
| 456           |                     |      |
|               | 3213                |      |
|               | 5656                |      |
| 123           |                     |      |

Now I need a vlookup formula which will first lookup in the employee code column if number is there then substitute the result but if employee code is empty then lookup in the employee station no and substitute the result现在我需要一个 vlookup 公式,如果数字存在则首先在员工代码列中查找,然后替换结果,但如果员工代码为空,则在员工站号中查找并替换结果

=IFERROR(VLOOKUP(*employee code*, *TABLE*,2,false),VLOOKUP(*employee station no*, *TABLE*,2,false)

Considering that the first table is "Sheet1" and the second table is "Sheet2" and the first cell on both tables is A1 , try this one.考虑到第一个表是"Sheet1" ,第二个表是"Sheet2" ,两个表上的第一个单元格都是A1 ,试试这个。 (If not, just modified according to your data) (如果没有,就根据你的数据修改)

=IF(AND(A2<>"",B2=""),VLOOKUP(A2,Sheet1!$A$12:$B$15,2,FALSE),IF(AND(A2="",B2<>""),VLOOKUP(B2,Sheet1!$A$12:$B$15,2,FALSE),"Check Data!!"))

The initial condition will check if there is value (any) in the Employee code but no Station and you will get your VLOOKUP there, if it is not the case, it will search by station and not employee.初始条件将检查员工代码中是否有值(任何)但没有站点,您将在那里获得VLOOKUP ,如果不是,它将按站点而不是员工进行搜索。 In the remaining scenarios (no data or Station and employee data) an error message is shown.在其余情况下(无数据或工作站和员工数据)显示错误消息。

EDIT编辑

If you want to receive a value when both cells have value then use:如果您想在两个单元格都有值时接收一个值,请使用:

=IF(A2<>"",VLOOKUP(A2,Sheet1!$A$12:$B$15,2,FALSE),IF(B2<>"",VLOOKUP(B2,Sheet1!$A$12:$B$15,2,FALSE),"Check Data!!"))

Hope it helps!希望能帮助到你!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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