简体   繁体   中英

How to cross reference two columns to apply the output from one of the column?

Column A1: date A2:1/1/2014

Column B1: item B2:Apple

Column C1: price C2:

Column D1:_____D2:

Column E1: item E2:Apple E3:banana

Column F1: price F2: $0.99F3:$1.99

So basically, how can I put that 'apple' price to column C2 when I type 'apple' in B2 column? I'm tring to apply the function to all rows in B column so whenever I type apple or banana it will automatically output the price from F column into C column.

also I want column C to remain blank until I put item name in column B. Please let me know the formula for that function.

I try to work with 'IF' function [=IF(B2=E2:E3,F2:F3,"")] but it seems like I doing something wrong.

You can use the VLOOKUP function to achieve this. In cell C2 you would want this: =IFERROR(VLOOKUP(B2,E2:F3,2,FALSE), "")

Here's a breakdown of VLOOKUP() parameters...

  • B2 is the lookup value (ie the value you want to lookup the price for in your price table)
  • E2:F3 is the range for your lookup table. If you had more items you would adjust this accordingly. For example, if you added pears and grapes to your list, you would use E2:F5 .
  • 2 means to use the second column in your lookup table. This is the value you are interested in.
  • FALSE means to find an exact match in your lookup table.

The IFERROR() function takes a statement (such as the VLOOKUP function) and attempts to calculate the answer. If it's able to do so without error, it returns the result of the statement, otherwise it returns the second value, which is just an empty string "" in this case.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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