ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Macro that sums cells in rows of varible number and.... (https://www.excelbanter.com/excel-programming/379732-macro-sums-cells-rows-varible-number.html)

blazzzercat

Macro that sums cells in rows of varible number and....
 
I need a macro that will SUM the cells in rows that vary in the number of
rows and put the total in the column next to the last number before a blank
row. It will then go down the column until it finds another row with a number
in it and SUM those rows until the next blank row, loop until no more rows
with numbers are found. The cells always start in I-8. I need the totals in
column J.

Thanks so much in advance.


Jef Gorbach

Macro that sums cells in rows of varible number and....
 
give this a shot

Sub test()
'place a subtotal in column(J) wherever column(I) has a blank cell
lrow = Range("i65536").End(xlUp).Row + 1
For Each cell In Range("i8:i" & lrow)
If cell.Value = isblank Then
cell.Offset(0, 1).Formula = "=SUM(R[" & -rowcount &
"]C[-1]:R[-1]C[-1])"
rowcount = 0
Else
rowcount = rowcount + 1
End If
Next
End Sub


"blazzzercat" <u30352@uwe wrote in message news:6b0307dd832cf@uwe...
I need a macro that will SUM the cells in rows that vary in the number of
rows and put the total in the column next to the last number before a

blank
row. It will then go down the column until it finds another row with a

number
in it and SUM those rows until the next blank row, loop until no more rows
with numbers are found. The cells always start in I-8. I need the totals

in
column J.

Thanks so much in advance.




blazzzercat via OfficeKB.com

Macro that sums cells in rows of varible number and....
 
Thanks Jef....works good.

Jef Gorbach wrote:
give this a shot

Sub test()
'place a subtotal in column(J) wherever column(I) has a blank cell
lrow = Range("i65536").End(xlUp).Row + 1
For Each cell In Range("i8:i" & lrow)
If cell.Value = isblank Then
cell.Offset(0, 1).Formula = "=SUM(R[" & -rowcount &
"]C[-1]:R[-1]C[-1])"
rowcount = 0
Else
rowcount = rowcount + 1
End If
Next
End Sub

I need a macro that will SUM the cells in rows that vary in the number of
rows and put the total in the column next to the last number before a blank

[quoted text clipped - 4 lines]

Thanks so much in advance.


--
Message posted via OfficeKB.com
http://www.officekb.com/Uwe/Forums.a...mming/200612/1



All times are GMT +1. The time now is 07:13 AM.

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