Why does .Sum("B2:F2") generate "Unable to get the Property of the WorksheetFunction class" error?

excel, vba

Solution

On it's own `"B2:F2"` is just a string. If you want to use it as a range then you will have to specifically specify that.

Change

AESum = Application.WorksheetFunction.Sum("B2:F2")

to

AESum = Application.WorksheetFunction.Sum(.Range("B2:F2"))

Problem

Even when I try to sum a row of values. I tried `worksheetfunction.mmult` but I get the same error. Do I need to add more references to my Excel? ``` Sub GetObj() Dim Obj As Double Dim VB1, VB2, AESum As Double Dim range1, range2, cell1, cell2 As Range With Worksheets("Result") AESum = Application.WorksheetFunction.Sum("B2:F2") End With End Sub ```

Original source