Sum of Sumif across multiple sheets using VBA

gt213

Board Regular
Joined
Jul 5, 2016
Messages
61
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
 

Excel Facts

What does custom number format of ;;; mean?
Three semi-colons will hide the value in the cell. Although most people use white font instead.

Forum statistics

Threads
1,223,264
Messages
6,171,081
Members
452,377
Latest member
bradfordsam

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