Sum across worksheets multiple criterias

Fin Fang Foom

Well-known Member
Joined
Mar 20, 2005
Messages
598
Hi everyone I really need some help.

I'm trying to get this formula below to work across multiple worksheets.

=SUM(IF(RIGHT(C3:C15,5)<>"Total",IF(D1:G1="Bonus",IF(ISNUMBER(D3:G15),D3:G15))))


So what I did I tried to modified into this?

Code:
=SUM(IF(RIGHT(OFFSET(INDIRECT("'"&C2:D2&"'!C3:C15")
,ROW(INDIRECT("3:15"))-3,0,1)),5)<>"Total",
IF(N(OFFSET(INDIRECT("'"&C2:D2&"'!D1:G1"),
ROW(INDIRECT("3:15"))-3,0,1))="Bonus",
ISNUMBER(N(OFFSET(INDIRECT("'"&C2:D2&"'!D3:G15"),
ROW(INDIRECT("3:15"))-3,0,1))),
N(OFFSET(INDIRECT("'"&C2:D2&"'!D3:G15"),ROW(INDIRECT("3:15"))-3,0,1))))


But it gives me a value error.

I can't use any Add-ins or vba for this. Hopefully we could get this formula to work above.


Here is an small example I Have, If you have notice the word bonus appears in 2 different columns.
Sum Across Worksheets.xls
ABCDEFG
1HoursDownBonus
2DateSHClockWorkedTimeHours
3105062224330-1.20
410506222435.250.48-0.18
510506222438.251-0.17
610506222431.20.20.29
743 Total3.5-1.26
8
910506222443.180.83-2.33
1044 Total8.51-2.33
11
1210506222450.3710.23
1310506222452.6201.69
1410506222451.550.484.01
1545 Total2.875.94
16
Sheet2
Sum Across Worksheets.xls
ABCDEF
1DownBonus
2DateSHClockTimeHours
310506221211.430.43
410506221211.100.45
510506221211.49-0.11
621 Total0.77
7
810506221276.302.60
910506221270.670.19
1010506221271.940.42
1110506221272.750.75
1227 Total3.97
13
Sheet3
 

Excel Facts

How to calculate loan payments in Excel?
Use the PMT function: =PMT(5%/12,60,-25000) is for a $25,000 loan, 5% annual interest, 60 month loan.
Hi
this formula gives sum of 3 sheets range A2 to B12. you can probably modify it to suit your data range.

=SUM(Sheet1:Sheet3!A2:B12)
Ravi
 
Upvote 0
Hi
this formula gives sum of 3 sheets range A2 to B12. you can probably modify it to suit your data range.

=SUM(Sheet1:Sheet3!A2:B12)
Ravi


Thanks ravishankar But the formula I'm trying to devise is a bit more complicated.
 
Upvote 0
I dont know what I'm missing I adjust the OFFSET function Width it should work but it does not.

Any Ideas?


Code:
=SUM(IF(RIGHT(T(OFFSET(INDIRECT("'"&$C$2:$C$3&"'!C3"),
COLUMN(INDIRECT("3:15"))-3,0,1)),5)<>"Total",
IF(T(OFFSET(INDIRECT("'"&$C$2:$C$3&"'!D1"),
COLUMN(INDIRECT("1:1"))-1,0,1,5))="Bonus",
ISNUMBER(N(OFFSET(INDIRECT("'"&$C$2:$C$3&"'!D3"),
COLUMN(INDIRECT("3:15"))-3,0,15,20))),
N(OFFSET(INDIRECT("'"&$C$2:$C$3&"'!D3"),
COLUMN(INDIRECT("3:15"))-3,0,15,20)))))
 
Upvote 0
Defined Names

ArrayA:

=COUNTIF(OFFSET(INDIRECT("'"&Sheet1!$C$2:$D$2&"'!C3:C15"),ROW(INDIRECT("3:15"))-3,,1),"<>*")

ArrayB:

=N(OFFSET(INDIRECT("'"&Sheet1!$C$2:$D$2&"'!"&Col),ROW(INDIRECT("3:15"))-3,,1))

Col:

=CHOOSE(Pos,"D3:D15","E3:E15","F3:F15","G3:G15")

Pos:

=TRANSPOSE(MMULT((T(OFFSET(INDIRECT("'"&TRANSPOSE(Sheet1!$C$2:$D$2)&"'!D1:G1"),,COLUMN(INDIRECT("D:G"))-4,,1))="Bonus")*(COLUMN(INDIRECT("D:G"))-4+1),TRANSPOSE(COLUMN(INDIRECT("D:G"))^0)))

Formula

=SUM(IF(ArrayA,ArrayB))

...confirmed with CONTROL+SHIFT+ENTER.

Hope this helps!
 
Upvote 0
WOW :pray: Domenic!!


How long it took you to come up with that? Its perfect!! Thank You!

One more thing when I tried to expand ranges to Column D through Column X I get a #REF! error. Here are the formulas I tried to modified.

ArrayA =COUNTIF(OFFSET(INDIRECT("'"&Sheet1!$C$2:$E$2&"'!C3:C200"),ROW(INDIRECT("3:200"))-3,,1),"<>*")
ArrayB =N(OFFSET(INDIRECT("'"&Sheet1!$C$2:$E$2&"'!"&Col),ROW(INDIRECT("3:200"))-3,,1))
Col =CHOOSE(Pos,"D3:D200","E3:E200","F3:F200","G3:G200","H3:H200","I3:I200","J3:J2005","K3:K200","L3:L200","M3:M200","N3:N200","O3:O200","Q3:Q200","R3:R200","S3:S200","T3:T200","U3:U200","V3:V200","W3:W200","x3:X200")
Pos =TRANSPOSE(MMULT((T(OFFSET(INDIRECT("'"&TRANSPOSE(Sheet1!$C$2:$E$2)&"'!D1:X1"),,COLUMN(INDIRECT("D:X"))-15,,1))="Bonus")*(COLUMN(INDIRECT("D:X"))-15+1),TRANSPOSE(COLUMN(INDIRECT("D:X"))^0)))


Am I missing something?
 
Upvote 0
...Thank You!...

You're very welcome!

Pos =TRANSPOSE(MMULT((T(OFFSET(INDIRECT("'"&TRANSPOSE(Sheet1!$C$2:$E$2)&"'!D1:X1"),,COLUMN(INDIRECT("D:X"))-15,,1))="Bonus")*(COLUMN(INDIRECT("D:X"))-15+1),TRANSPOSE(COLUMN(INDIRECT("D:X"))^0)))

The number 15 should remain 4. Instead of 4 (now 15), I probably should have used the following...

COLUMN(INDIRECT("D:D"))

It would have made it easier to adapt it to your spreadsheet.
 
Upvote 0
Hi Domenic,


I changed the column reference but still getting the #REF! error.


Pos =TRANSPOSE(MMULT((T(OFFSET(INDIRECT("'"&TRANSPOSE(Sheet1!$C$2:$E$2)&"'!D:D"),,COLUMN(INDIRECT("D:D"))-15,,1))="Bonus")*(COLUMN(INDIRECT("D:D"))-15+1),TRANSPOSE(COLUMN(INDIRECT("D:D"))^0)))
 
Upvote 0
The formula should be as follows...

=TRANSPOSE(MMULT((T(OFFSET(INDIRECT("'"&TRANSPOSE(Sheet1!$C$2:$E$2)&"'!D1:X1"),,COLUMN(INDIRECT("D:X"))-COLUMN(INDIRECT("D:D")),,1))="Bonus")*(COLUMN(INDIRECT("D:X"))-COLUMN(INDIRECT("D:D"))+1),TRANSPOSE(COLUMN(INDIRECT("D:X"))^0)))
 
Upvote 0

Forum statistics

Threads
1,215,328
Messages
6,124,299
Members
449,149
Latest member
mwdbActuary

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