无法获取工作表函数类的Sumif属性

时间:2013-04-25 07:55:45

标签: excel excel-vba vba

有谁可以解释我能做些什么来解决这个问题?

enter image description here

这是当前的代码:

SumFinalUnusedSPQCement = WorksheetFunction.Sum(Application.WorksheetFunction.SumIf(Range("V4:V" & lastRow + 3), ">0", "B4:B" & lastRow + 3))
SumFinalUnusedSPQSand = WorksheetFunction.Sum(Application.WorksheetFunction.SumIf(Range("W4:W" & lastRow + 3), ">0", "C4:C" & lastRow + 3))
SumFinalUnusedSPQAggregate = WorksheetFunction.Sum(Application.WorksheetFunction.SumIf(Range("X4:X" & lastRow + 3), ">0", "D4:D" & lastRow + 3))

1 个答案:

答案 0 :(得分:2)

您在Range之前缺少B4:B,而其他人则相同。它应该是

SumFinalUnusedSPQCement = Application.WorksheetFunction.SumIf( _
                                      Range("V4:V" & lastRow + 3), _
                                      ">0", _
                                      Range("B4:B" & lastRow + 3) _
                                      )

此外,您不需要WorksheetFunction.Sum