Sumifs, vlookup, match and 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. 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

Which came first: VisiCalc or Lotus 1-2-3?
Dan Bricklin and Bob Frankston debuted VisiCalc in 1979 as a Visible Calculator. Lotus 1-2-3 debuted in the early 1980's, from Mitch Kapor.
This might lead to more questions than answers, but...

Using the example you've given there...

In Sheet 2 A2 use;

Code:
=IFERROR(INDEX(Sheet1!$A$2:$A$7,MATCH(0,COUNTIF(Sheet1!F$1:$F1,Sheet1!$A$2:$A$7),0)),"")

It is an array formula so you'll need to confirm with CTRL, Shift and Enter (if done correctly you'll get "{" at the start of the formula and "}" at the end of it).

In Sheet 2 B2 use;

Code:
=SUMIF(Sheet1!A:A,A2,Sheet1!B:B)

It's probably not a perfect solution but it might put you on the right path :)
 
Upvote 0
Thank you for your answer! I see what you mean.

The point is, at Sheet1 the headers (so let's call it row A) are dynamic.
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..
 
Upvote 0
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..

Ahhhhhhhhhh. Right - So you'd need to find the Column with the data in before you can make the list?

That is a bit beyond me I'm afraid to say, I've had a quick play but can't get it to work - I do feel as though it should be doable though, if I think of something I'll come back.
 
Upvote 0

Forum statistics

Threads
1,215,051
Messages
6,122,872
Members
449,097
Latest member
dbomb1414

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