简体   繁体   English

Excel VBA SUMIF运行时错误“ 424”:必需对象

[英]Excel VBA SUMIF Run-time error '424': Object Required

This produces an Error: Run-time error '424': Object Required 这将产生错误:运行时错误“ 424”:必需对象

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 一切似乎都已正确定义和实例化,每个数组的元素均为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. 我尝试将MaxGrad放到Range中,然后在SUMIF中引用Range,但这也不起作用。

You cannot use SUMIF with arrays. 您不能将SUMIF与数组一起使用。

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. SUMIF()工作表函数可以使用的条件限于文本,数字或范围,并且该函数不能使用数组常量。

https://support.microsoft.com/en-us/help/275165/when-to-use-a-sum-if-array-formula https://support.microsoft.com/en-us/help/275165/when-to-use-a-sum-if-array-formula

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM