Sum Range

  • Thread starter FIRSTROUNDKO via OfficeKB.com
  • Start date
F

FIRSTROUNDKO via OfficeKB.com

Hi,

I selected this range

Range(ActiveCell.Offset(-lastrow + 2, 0), ActiveCell.Offset(-2, 0))

and I want to put its Sum 2 cells down

my code so far is

Dim lastrow As Long
lastrow = Cells(Rows.Count, 1).End(xlUp).Row

Range("B" & lastrow + 2).Select

Do Until Selection.Offset(-38, 0) = ""

Range(ActiveCell.Offset(-lastrow + 2, 0), ActiveCell.Offset(-2, 0))

Selection.Offset(0, 1).Select

Loop
 
F

FIRSTROUNDKO via OfficeKB.com

I solved it!

Dim uprow As Double
Dim lastrow As Long
lastrow = Cells(Rows.Count, 1).End(xlUp).Row

uprow = lastrow - 2

Range("B" & lastrow + 2).Select

Do Until Selection.Offset(-38, 0) = ""

ActiveCell.FormulaR1C1 = "=SUM(R[-" & uprow & "]C:R[-2]C)"

Selection.Offset(0, 1).Select

Loop
 

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