0

I have two cell addresses stored in my two variables saddr and eaddr (starting and ending cell addresses respectively)

I have to find the some of all cells in between the range and have the value assigned to another random cell. My code below throws an error. I am pretty sure i am not using the variable containing the cell addresses in the right format. Please help

Code:

saddr = Cells(x, 3).Address
eaddr = Cells(x, (3 + 6)).Address
Worksheets("Sheet2").Range("C2").Select
ActiveCell.Formula = "=Sum(Sheet1!:"&saddr&":"&eaddr&")"

The last line throws up this error. Can you tell me how to use the variable cell references correctly in the formula?

bhavya
  • 1
  • 1

1 Answers1

0

You probably want

ActiveCell.Formula = "=Sum(Sheet1!" & saddr & ":" & eaddr & ")"

Even if this gets you going, you better check/fix a few things. I strongly recommend you check this.

Community
  • 1
  • 1