summing through end of row

T

tbmarlie

I'm trying to sum using vb from cell e3 to the bottom of the row which
will be a variable number of rows. For some reason, it doesn't like
the last line in my code. I think I may have done something wrong at
the end of the last line.

Dim Rng As Range
Set Rng = Range ("e3").End(xlDown)
rng.Offset (1,0).Formula="=SUM(E"&rng.row&")"
 
D

Dave Peterson

Dim Rng as range
set rng = activesheet.range("E3").end(xldown)
rng.offset(1,0).formular1c1 = "=sum(r1C:r[-1]c)"

Sometimes using the .formulaR1C1 reference style makes coding a lot easier. And
the user will still see the formula using the settings that they like.

R1C is Row 1 of the same column
R[-1]C is the row above the cell getting the formula, but the same column
 
D

Dave Peterson

And if you wanted from Row 3, then the .formular1c1 would be:

rng.offset(1,0).formular1c1 = "=sum(r3c:r[-1]c)"

(I didn't notice that portion of your question...)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top