ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   NEWBIE: How to sum cells using VBA (https://www.excelbanter.com/excel-programming/367375-newbie-how-sum-cells-using-vba.html)

chuber

NEWBIE: How to sum cells using VBA
 
Brand new and trying my best at VBA ... in advance, thank you for your
help!

My worksheets will have a different number of rows each time they are
generated. Trying to show the sum for Column C, Column D and Column E
(individually). I can write the code to show the sum, but it requires
that I have the cursor in the specific cell.

Want to be able to run the macro, have it find the last row with
numbers, then jump down one row and show the sum for each column.

--Chris


Bob Phillips

NEWBIE: How to sum cells using VBA
 
As an example

iLastRow = Cells(Rows.Count,"D").End(xlUp).Row

Cells(iLastRow+1,"D").Formula = "=SUM(D1:D" & iLastRow & ")"

--
HTH

Bob Phillips

(replace somewhere in email address with gmail if mailing direct)

"chuber" wrote in message
oups.com...
Brand new and trying my best at VBA ... in advance, thank you for your
help!

My worksheets will have a different number of rows each time they are
generated. Trying to show the sum for Column C, Column D and Column E
(individually). I can write the code to show the sum, but it requires
that I have the cursor in the specific cell.

Want to be able to run the macro, have it find the last row with
numbers, then jump down one row and show the sum for each column.

--Chris





All times are GMT +1. The time now is 04:55 AM.

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