Sumifs with a dynamic header

Astrid123

New Member
Joined
Sep 25, 2017
Messages
16
Hello everybody

The following situation I'm struggling for some time right now, I feel like I'm close to solving it, though I do not succeed.

What I want:

Let's say that in sheet 1 I have one table containing data, with a header, names and amounts.
In sheet 2 I want to lookup the sum of amounts based on names and the dynamic header.

For example:

Table sheet 1:

AnimalCosts
Monkey8
Monkey5
Rabbit2
Dog1
Dog3
Monkey4

<tbody>
</tbody>


And sheet 2

Costs
Monkey17
Rabbit2
Dog4

<tbody>
</tbody>


I want the formula for B2, B3 and B4, but since the headers in sheet 1 are dynamically I don't want a fixed formula. Sheet 2, row A is not dynamic, the headers Animal and costs in this example I can just write it down. But for Sheet 1 the name Animal can be placed in column A but in column B or C or whatever as well. For this reason I want to apply the index match function. But I don't know exactly how to do this, I guess it needs to be something with Sumifs, Vlookup and match. But Im not sure how to do it exactly.


Hope you can help me out!
 

Excel Facts

Round to nearest half hour?
Use =MROUND(A2,"0:30") to round to nearest half hour. Use =CEILING(A2,"0:30") to round to next half hour.
Hi,

Try this :

Crtl+Shift+Enter NOT just Enter and change "Animal"=Sheet1!$A$1:$B$1 as needed...


=SUM((IF("Animal"=Sheet1!$A$1:$B$1,IF(Shet2!A2=Sheet1!$A$2:$A$7,Sheet1!$B$2:$B$7))))
 
Upvote 0
This might get you started it, it uses sum instead of sumif but the technique is the same;

=SUM(OFFSET(A2,0,MATCH("Animal",A1:T1,0),7,1))

Change the last colum T1 as required, and the "height" 7 must be change as required too.
 
Upvote 0
If you have a table on Sheet 1 (say, Table1), then just use

=SUMIF(Table1[Animal],A2,Table1[Costs])
 
Upvote 0

Forum statistics

Threads
1,214,971
Messages
6,122,520
Members
449,088
Latest member
RandomExceller01

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