Determining a row's referenced row for another

2019-09-01 01:53发布

问题:

I have a table that includes an "inventory" item's name, as well as its base weight and associated carbs, protein, fat, etc. On another sheet, there's a table that references the inventory item's name, and once I input the actual weight, I'd like my other calculated columns to automatically figure out the carbs, protein, fat, etc. for that selected item and weight. For example...

My "inventory" sheet:

Item                      Amount   Unit   Calories   Carbs   Protein   Fat
Chicken Thigh (w/ Bone)   1        oz     37         0       3.73      2.3

And my list of items eaten, sold, whichever: This is the rendered table

Item:                     Measure   Unit   Carbs   Protein   Fat
Chicken Thigh (w/ Bone)   4.6   

And the raw formulas, or what I think they may be: I have no idea how to automatically select calories/carbs/etc to use for calculations :(

Item:           Measure   Unit   ... Carbs  ... Protein  ... Fat
=Inventory.A2   4.6       =Sheet/Row of A2's E column * B2

...anyone know how to do this in excel? Is it even possible?

回答1:

Assuming Measure is in B1, Unit in C1, you are not interested in Calories (so D1 is blank), Carbs/Protein/Fat are in E1:G1 respectively, then in C2:

=(IF(C$1="","",IF(ISTEXT(VLOOKUP($A2,Inventory!$A:$G,COLUMN(),0)),VLOOKUP($A2,Inventory!$A:$G,COLUMN(),0),$B2*VLOOKUP($A2,Inventory!$A:$G,COLUMN(),0))))  

and copied across to G2 might suit.