Formula to look up list of values in a range and then sum associated values

dommeehan

New Member
Joined
Aug 10, 2020
Messages
15
Office Version
  1. 365
Platform
  1. Windows
Hi I'd like a formula in B12:H12 that assesses all the food eaten over the course of the day and then matches within the reference table (N2:P12) and returns the sum of all the protein consumed. For example, B12 would show 103. I then need a similar formula for calories so B13 would show 885.

Food.xlsx
ABCDEFGHIJKLMNOP
2MondayTuesdayWednesdayThursdayFridaySaturdaySundayFoodProteinCalories
3BreakfastBoiled EggBoiled EggBoiled EggBoiled EggBoiled EggBoiled EggBoiled EggBoiled Egg660
4YoghurtYoghurtYoghurtYoghurtYoghurtYoghurtYoghurtYoghurt18110
5LunchTunaPrawnsTunaPrawnsTunaPrawnsTunaTuna25100
6KaleKaleKaleKaleKaleKaleKaleKale320
7NutsNutsNutsNutsNutsNutsNutsNuts12150
8DinnerChickenSalmonSalmonChickenSalmonChickenChickenChicken30180
9BroccoliBroccoliBroccoliBroccoliBroccoliBroccoliBroccoliBroccoli525
10PotatoPotatoPotatoPotatoPotatoPotatoPotatoPotato4240
11Prawns15170
12ProteinSalmon24220
13Calories
Schedule
 

Excel Facts

What is the fastest way to copy a formula?
If A2:A50000 contain data. Enter a formula in B2. Select B2. Double-click the Fill Handle and Excel will shoot the formula down to B50000.
How about
+Fluff 1.xlsm
ABCDEFGHIJKLMNOP
1
2MondayTuesdayWednesdayThursdayFridaySaturdaySundayFoodProteinCalories
3BreakfastBoiled EggBoiled EggBoiled EggBoiled EggBoiled EggBoiled EggBoiled EggBoiled Egg660
4YoghurtYoghurtYoghurtYoghurtYoghurtYoghurtYoghurtYoghurt18110
5LunchTunaPrawnsTunaPrawnsTunaPrawnsTunaTuna25100
6KaleKaleKaleKaleKaleKaleKaleKale320
7NutsNutsNutsNutsNutsNutsNutsNuts12150
8DinnerChickenSalmonSalmonChickenSalmonChickenChickenChicken30180
9BroccoliBroccoliBroccoliBroccoliBroccoliBroccoliBroccoliBroccoli525
10PotatoPotatoPotatoPotatoPotatoPotatoPotatoPotato4240
11Prawns15170
12Protein1038797939793103Salmon24220
13Calories885995925955925955885
Holder
Cell Formulas
RangeFormula
B12:H12B12=SUM(FILTER($O$3:$O$12,COUNTIF(B3:B10,$N$3:$N$12)))
B13:H13B13=SUM(FILTER($P$3:$P$12,COUNTIF(B3:B10,$N$3:$N$12)))
 
Upvote 0
This is great, thanks! Is there anyway to make that formula multiple proof? E.g. in the below example, some items appear twice and the formula you suggested doesn't account for that. Thanks for any help in advance.

Food.xlsx
ABCDEFGHIJKLMNOP
2MondayTuesdayWednesdayThursdayFridaySaturdaySundayFoodProteinCalories
3BreakfastBoiled EggBoiled EggBoiled EggBoiled EggBoiled EggBoiled EggBoiled EggBoiled Egg660
4YoghurtYoghurtYoghurtYoghurtYoghurtYoghurtYoghurtYoghurt18110
5LunchTunaPrawnsTunaPrawnsTunaPrawnsTunaTuna25100
6KaleKaleKaleKaleKaleKaleKaleKale320
7NutsNutsNutsNutsNutsNutsNutsNuts12150
8DinnerChickenSalmonSalmonChickenSalmonChickenChickenChicken30180
9BroccoliBroccoliBroccoliBroccoliBroccoliBroccoliBroccoliBroccoli525
10PotatoPotatoPotatoPotatoPotatoPotatoPotatoPotato4240
11SnackBoiled EggPrawns15170
12YoghurtSalmon24220
13
14Protein
15Calories
Schedule
 
Upvote 0
Surely you would still want to add them. :unsure: After all if you have eaten 2 boiled eggs that's 120 calories not 60.
 
Upvote 0
Correct, but when I use the formula you suggested it doesn't add the protein / calorie amount twice it just counts it as one, irrespective of how many times it appears.
 
Upvote 0
Ok, how about
Excel Formula:
=SUM(SUMIFS($O$3:$O$12,$N$3:$N$12,B3:B12))
 
Upvote 0
You're welcome & thanks for the feedback.
 
Upvote 0

Forum statistics

Threads
1,214,978
Messages
6,122,549
Members
449,089
Latest member
davidcom

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top