ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   How do I sum a column of unknown length using a macro (https://www.excelbanter.com/excel-programming/343924-how-do-i-sum-column-unknown-length-using-macro.html)

SandyPaul

How do I sum a column of unknown length using a macro
 


Gary Keramidas

How do I sum a column of unknown length using a macro
 
this would sum everythiing in column B starting in b4

Sub test()
lastrow = Worksheets("Sheet1").Cells(Rows.Count, "B").End(xlUp).Row

Range("B" & lastrow + 1).Formula = "=sum(B4:B" & lastrow & ")"

End Sub

--


Gary


"SandyPaul" wrote in message
...





All times are GMT +1. The time now is 03:46 PM.

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