From: FIRSTROUNDKO via OfficeKB.com on
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

--
Message posted via OfficeKB.com
http://www.officekb.com/Uwe/Forums.aspx/excel-programming/201002/1

From: FIRSTROUNDKO via OfficeKB.com on
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

FIRSTROUNDKO wrote:
>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

--
Message posted via OfficeKB.com
http://www.officekb.com/Uwe/Forums.aspx/excel-programming/201002/1