ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   VBA SUM (https://www.excelbanter.com/excel-programming/282288-vba-sum.html)

Edgar[_3_]

VBA SUM
 
Is there some way of adding some VBA to add a sum formula
in the last row of some data i have. I would need the sum
in Column C.

Thanks



Chip Pearson

VBA SUM
 
Edgar,

Try something like the following:

Dim Rng As Range
Set Rng = Cells(Rows.Count, "C").End(xlUp)(2, 1)
Rng.Formula = "=SUM(C1:" & Rng(0, 1).Address(False, False) & ")"


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com


"Edgar" wrote in message
...
Is there some way of adding some VBA to add a sum formula
in the last row of some data i have. I would need the sum
in Column C.

Thanks






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

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