简体   繁体   中英

Lookup value in another sheet based on name

I have a file that has:

sheet 1:

Name  Hours Price
-----------------
Name1 12    126.00 
Name2 14    161.00
Name3 8     100.00
Name4 10    135.00

sheet 2:

Name  Rate
---------
Name1 10.5
Name2 11.5
Name3 12.5
Name4 13.5

I want to multiply Hours by the names corresponding rate. So like Name1 = 12 * 10.5 = 126 and so on. Not sure how to do this?

One way would be to use VLOOKUP :

(assuming Name is in A1 in both sheets):

The formula in the Price column (C3 through C6) should be

=B3*VLOOKUP(A3,Sheet2!$A$3:$B$6,2,FALSE)

translated:

=  B3   *VLOOKUP(  A3  ,  Sheet2!$A$3:$B$6   ,      2     ,     FALSE   )
={Hours}*VLOOKUP({Name},{Name+Rate in Sheet2},{2nd column},{exact match})

I think an rlly easy way if you want to do it over "code" in a excelcell then like this:

=IF(A1=Table2!A1;B1*Table2!B1)

=IF(CELL = CELL; THEN DO; ELSE DO)

If the names can be changing in the order, D Stanleys is better.

Otherwise VBA-Code would be also easy.

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