Search and sum

JackM95

New Member
Joined
Jun 26, 2024
Messages
4
Office Version
  1. 365
Platform
  1. Windows
Hi all,

I am struggling to try and find a formula that will help me with what I am trying to achieve.

Basically what I would like to have is a summary on a separate sheet that shows totals of specific headings, extracted from a report on another sheet.

The thing that is troubling me is that the columns change when the report is run so for example, the heading 'Expenses' that might be in column D one month, is now in column G in the next month. Additionally, the number of rows also change month to month depending on how many people there are. The only constant in this is that row 7 is ALWAYS the row that has the headings. Please see below an example:

Sheet 1

1719407346372.png


Sheet 2

1719407407056.png


Any help would be greatly appreciated.

Thanks
 

Excel Facts

Can a formula spear through sheets?
Use =SUM(January:December!E7) to sum E7 on all of the sheets from January through December
you can use
=SUMPRODUCT(($C$7:$F$7=H7)*($C$8:$F$40))
BUT add the sheet names in

Book2
ABCDEFGHI
1
2
3
4
5
6
7foodrentexpenses travelfood4
8Person1rent12
9Person2134expenses15
10Person31234 travel20
11Person41234
12Person51234
13Person6234
14Person72
15Person82
16Person9
17Person10
18Person11
19Person12
20Person13
21Person14
22Person15
23Person16
24Person17
25Person18
26Person19
27Person20
28Person21
29Person22
30
Sheet1
Cell Formulas
RangeFormula
H7:H10H7=TOCOL(C7:F7)
I7:I10I7=SUMPRODUCT(($C$7:$F$7=H7)*($C$8:$F$40))
Dynamic array formulas.
 
Upvote 0
If you truly have a totals row at the bottom of each column, you may need to divide etaf's SUMPRODUCT total formula by 2, i.e.
Excel Formula:
=SUMPRODUCT(($C$7:$F$7=H7)*($C$8:$F$40))/2
 
Upvote 0
Hi, here's another way you could try where you can use full column references without a big hit to performance.

Book1
ABCDEFGHI
1
2
3
4
5
6
7foodrentexpenses travelfood4
8Person1rent12
9Person2134expenses15
10Person31234 travel20
11Person41234
12Person51234
13Person6234
14Person72
15Person82
16Person9
17Person10
18Person11
19Person12
20Person13
21Person14
22Person15
23Person16
24Person17
25Person18
26Person19
27Person20
28Person21
29Person22
304121520
Sheet1
Cell Formulas
RangeFormula
H7:H10H7=TOCOL(C7:F7)
I7:I10I7=SUM(XLOOKUP(H7,$C$7:$F$7,C:F))/2
Dynamic array formulas.
 
Upvote 0
Thanks for the help both.

It works on the example workbook I created however when I try and do the same thing in the workbook I need it in, the value returns with #N/A. Looking at the formula evaluation tool, it picks up the heading correctly in the first half of the formula but it doesn't seem to like the second part of the formula. It only seems to work when I do the range on that specific column (below - column P) but if I try to add in any extra columns, I get the #N/A. Below I have done the full table but even if I in the second part of the formula I do (PS!$O$8:$P$40), it doesn't like it.

Would you know why this might be? Hopefully I explained this well enough for you to understand!

Thanks again for the help.

1719411608996.png


1719411710170.png
 

Attachments

  • 1719411645192.png
    1719411645192.png
    14.2 KB · Views: 1
Upvote 0
Hi, here's another way you could try where you can use full column references without a big hit to performance.

Book1
ABCDEFGHI
1
2
3
4
5
6
7foodrentexpenses travelfood4
8Person1rent12
9Person2134expenses15
10Person31234 travel20
11Person41234
12Person51234
13Person6234
14Person72
15Person82
16Person9
17Person10
18Person11
19Person12
20Person13
21Person14
22Person15
23Person16
24Person17
25Person18
26Person19
27Person20
28Person21
29Person22
304121520
Sheet1
Cell Formulas
RangeFormula
H7:H10H7=TOCOL(C7:F7)
I7:I10I7=SUM(XLOOKUP(H7,$C$7:$F$7,C:F))/2
Dynamic array formulas.

Actually I think this works. Seems to work on my spreadsheet but will try on another and see if I get the same result.

Thank you :)
 
Upvote 0
you are looking for TOTAL
does that exist in A7:AO7
does it have any spaces after total ?
often extracted info can have spaces and so you get the error

the range is P to P
NOT the same as the headers
A8:AO40
to match the headers

difficult with images which do not match the test
(PS!$O$8:$P$40),
how does that match with the headers
 
Upvote 0
Hi all

Thanks for all your help, the formula given seems to work.

Really appreciate you taking the time to help me.

Jack
 
Upvote 0

Forum statistics

Threads
1,223,970
Messages
6,175,721
Members
452,667
Latest member
vanessavalentino83

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