ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Sum unknown length column data in VBA (https://www.excelbanter.com/excel-programming/302592-sum-unknown-length-column-data-vba.html)

John[_80_]

Sum unknown length column data in VBA
 
All, I really appreciate the help from this group of talented people.

I want to add a formula in the 6th column, one row after the bottom
row of data, summing from F5 to F "bottom".
I know I'm close, but something here is wrong.

Sub ColTots()

Dim z As Long
Dim bottom As Long

bottom = Cells(Rows.Count, "B").End(xlUp).Row
z = bottom + 1

cells(z,6).formula = "=SUM("F5:F" & bottom)"


Thanks
john

Norman Jones

Sum unknown length column data in VBA
 
Hi John,

Try:

Cells(z, 6).Formula = "=SUM(F5:F" & bottom & ")"


---
Regards,
Norman


"John" wrote in message
...
All, I really appreciate the help from this group of talented people.

I want to add a formula in the 6th column, one row after the bottom
row of data, summing from F5 to F "bottom".
I know I'm close, but something here is wrong.

Sub ColTots()

Dim z As Long
Dim bottom As Long

bottom = Cells(Rows.Count, "B").End(xlUp).Row
z = bottom + 1

cells(z,6).formula = "=SUM("F5:F" & bottom)"


Thanks
john




john

Sum unknown length column data in VBA
 

Sub Macro1()
'
' Macro1 Macro
'
Range("F5").End(xlDown).Name = "finish"
Range("finish").Offset(1, 0).Formula = "=SUM
(f5:finish)"
End Sub



-----Original Message-----
All, I really appreciate the help from this group of

talented people.

I want to add a formula in the 6th column, one row after

the bottom
row of data, summing from F5 to F "bottom".
I know I'm close, but something here is wrong.

Sub ColTots()

Dim z As Long
Dim bottom As Long

bottom = Cells(Rows.Count, "B").End(xlUp).Row
z = bottom + 1

cells(z,6).formula = "=SUM("F5:F" & bottom)"


Thanks
john
.


keepITcool

Sum unknown length column data in VBA
 
as a (simpler?) alternative I'd use:

.formular1c1 = "=sum(r5c:r[-1]c)"

keepITcool

< email : keepitcool chello nl (with @ and .)
< homepage: http://members.chello.nl/keepitcool


(John) wrote:

All, I really appreciate the help from this group of talented people.

I want to add a formula in the 6th column, one row after the bottom
row of data, summing from F5 to F "bottom".
I know I'm close, but something here is wrong.

Sub ColTots()

Dim z As Long
Dim bottom As Long

bottom = Cells(Rows.Count, "B").End(xlUp).Row
z = bottom + 1

cells(z,6).formula = "=SUM("F5:F" & bottom)"


Thanks
john




All times are GMT +1. The time now is 05:14 PM.

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