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
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