0

I got a problem with sum of rows formula in vba. I am using the below code. When I check the value in Range("H3").Formula its giving me the correct value =SUM(C5:G5)

But the problem is its not reflecting in the excel cell.

Range("H3").Formula = "=SUM(" & Range(Cells(5, 3), Cells(5, 7)).Address(False, False) & ")"
1
  • use .value instead of .formula Commented Mar 21, 2013 at 19:18

1 Answer 1

1

You need to fully qualify the cells (notice the dots). Try this

'~~> Replace this with the relevant sheet
With Sheets("Sheet1")
    .Range("H3").Formula = "=SUM(" & _
                          .Range(.Cells(5, 3), .Cells(5, 7)).Address(False, False) & _
                          ")"
End With
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.