Reputation: 873
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
Upvotes: 3
Views: 11543
Reputation: 839
Excel.WorksheetFunction.Sum(Range("J7:J8"))
this works for me!
Upvotes: 1
Reputation: 7993
You can change
AESum = Application.WorksheetFunction.Sum("B2:F2")
to
AESum = Application.WorksheetFunction.Sum(.Range("B2:F2"))
you could also evaluate the expression as:
AESum = [Sum(Result!B2:F2)]
Upvotes: 1
Reputation: 17475
Instead of Application.WorksheetFunction.Sum("B2:F2")
use Application.WorksheetFunction.Sum(.Range("B2:F2"))
!
Upvotes: 3
Reputation: 149305
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"))
Upvotes: 8