ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Sum Range (https://www.excelbanter.com/excel-programming/439958-sum-range.html)

FIRSTROUNDKO via OfficeKB.com

Sum Range
 
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.a...mming/201002/1


FIRSTROUNDKO via OfficeKB.com

Sum Range
 
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.a...mming/201002/1



All times are GMT +1. The time now is 06:30 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com