ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Adding Sum to bottom of Col C for all Sheets in Array (https://www.excelbanter.com/excel-programming/367080-adding-sum-bottom-col-c-all-sheets-array.html)

SITCFanTN

Adding Sum to bottom of Col C for all Sheets in Array
 
I have 10 sheets that are formatted with the currency in column C. I would
like to call a sub at the end of a macro to add the sum of col C to each
sheet in the workbook. My problem is each sheet has a variable number of
rows so I'm not sure how to say add empty row then add sum at bottom of
column C. Thank you

Ardus Petus

Adding Sum to bottom of Col C for all Sheets in Array
 
One solution would be to set your totals in column C65536, then hide all
unused rows.

HTH
--
AP

"SITCFanTN" a écrit dans le message de
news: ...
I have 10 sheets that are formatted with the currency in column C. I would
like to call a sub at the end of a macro to add the sum of col C to each
sheet in the workbook. My problem is each sheet has a variable number of
rows so I'm not sure how to say add empty row then add sum at bottom of
column C. Thank you




jetted[_10_]

Adding Sum to bottom of Col C for all Sheets in Array
 

Hi

You could try this code
Sub loop_worksheets()
Dim MyArray, MyInt
sheet_count = ActiveWorkbook.Sheets.Count
'Changes this for your worksheets
MyArray = Array("Sheet1", "Sheet2", "Sheet3")
For j = 0 To sheet_count - 1
sname = MyArray(j)
Sheets(sname).Select
rowcount = Cells(Cells.Rows.Count, "c").End(xlUp).Row
Range("c" & rowcount + 1).Select
ActiveCell.FormulaR1C1 = "=SUM(R[-" & rowcount & "]C:R[-1]C)"
Next
End Sub


--
jetted
------------------------------------------------------------------------
jetted's Profile: http://www.excelforum.com/member.php...o&userid=17532
View this thread: http://www.excelforum.com/showthread...hreadid=561047



All times are GMT +1. The time now is 09:44 PM.

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