Sum of Sumif across multiple sheets using VBA

gt213

Board Regular
Joined
Jul 5, 2016
Messages
59
Hi,

I'm trying to do a sum of sumif across multiple sheets, with an index match on the sum range.
This is the formula I have to do the sumif on one sheet, so I would like a sum of these (which would be on all but 3 of the sheets in the workbook:

=SUMIF('To be paid on 02-25-16'!A:A,Summary!A14,INDEX('To be paid on 02-25-16'!E2:P2,MATCH(Summary!B3,'To be paid on 02-25-16'!E2:P2,0)))

Doing some research on this I was able to find the following vba code, but when I enter the function in a cell it is giving #VALUE!.

Public Function AddItUp(x As Long) As Long
Dim RunningSum() As Variant
Dim i As Long, j As Long
j = ActiveWorkbook.Worksheets.Count
ReDim RunningSum(3 To j)
For i = 3 To j
RunningSum(i) = Application.SumIf(Worksheets(i).Range("A:A"), x, Worksheets(i).Range("e:e"))
Next i
AddItUp = Application.WorksheetFunction.Sum(RunningSum)
End Function

I guess I'm looking to combine the formula and the code together and then be able to drag the AddItUP function across and down a table so that the 'X' value and the 'MATCH(Summary!B3' update.

Many thanks
 

Some videos you may like

Excel Facts

Spell Check in Excel
Press F7 to start spell check in Excel. Be careful, by default, Excel does not check Capitalized Werds (whoops)

Watch MrExcel Video

Forum statistics

Threads
1,123,369
Messages
5,601,223
Members
414,434
Latest member
Riyen

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
Top