Reputation: 377
This produces an Error: Run-time error '424': Object Required
Private Function Y_Mode() As Double
Dim MaxGrad As Double
MaxGrad = WorksheetFunction.Max(Graduation_Series)
Y_Mode = WorksheetFunction.SumIf(Graduation_Series, MaxGrad, Y_Series)
End Function
It is failing on this line:
Y_Mode = WorksheetFunction.SumIf(Graduation_Series, MaxGrad, Y_Series)
Everything seems defined and instantiated properly and the elements of each array are of type Variant/Double
Watch : + : Graduation_Series : : Variant/Variant(0 to 14) : SU_Solution.Y_Mode
Watch : : MaxGrad : 474.281204765715 : Double : SU_Solution.Y_Mode
Watch : + : Y_Series : : Variant/Variant(0 to 14) : SU_Solution.Y_Mode
I tried putting MaxGrad into a Range and then referencing the Range in SUMIF, but that did not work either.
Upvotes: 2
Views: 712
Reputation: 377
You cannot use SUMIF with arrays.
The criteria that you can use with the SUMIF() worksheet function is limited to text, numbers, or a range, and the function cannot use array constants.
https://support.microsoft.com/en-us/help/275165/when-to-use-a-sum-if-array-formula
Upvotes: 3