Excel vlookup help

旧巷老猫 提交于 2019-12-01 11:24:30

问题


Using vlookup, when a match occurs, I want to display the value of column C from sheet 2 from the same row where the match occurred. The formula I came up with takes the value from column C sheet 2 but it takes it from the row where the formula is pasted on sheet 3 instead of where the match occurred.

Here's my formula that doesn't work:

=IF(VLOOKUP(Sheet1!A:A,Sheet2!A:A,1,FALSE),Sheet2!C:C,"NODATA")

How can I take the value from the row where the match occurred?


回答1:


You need to manually get the index you're looking for, then get the value at that index:

=INDEX(Sheet2!C:C, MATCH(Sheet1!A:A,Sheet2!A:A,FALSE))



回答2:


To be clear, I am not entirely certain I understand what you are trying to achieve. Maybe the following helps...

Suppose I have 3 sheets in a workbook as follows:

    Sheet1            Sheet2                 Sheet3
    A                 A    B    C            A     B
1   10                2    h    Apple        10    Apple
2   20                g    4    Banana       25    n/a
3   30                l    !    Pear         40    Grape
4   40                g    *    Grape        30    Pear

In column B of Sheet 3 I have the following formula:

=INDEX(Sheet2!$C$1:$C$4,MATCH(VLOOKUP(A1,Sheet1!$A$1:$A$4,1,FALSE),Sheet1!$A$1:$A$4,1))

To explain:

  • The VLOOKUP looks up the value from Sheet 3, Col A in Sheet1
  • The MATCH returns the row in Sheet1 of the VLOOKUP result
  • The INDEX then uses the row number to pick the right value from the value in Sheet2

Again, not sure if this is what you wanted exactly. It may help you get you started...



来源:https://stackoverflow.com/questions/5381620/excel-vlookup-help

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!