Macro that sums cells in rows of varible number and....

  • Thread starter Thread starter blazzzercat
  • Start date Start date
B

blazzzercat

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.
 
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
 
Thanks Jef....works good.

Jef said:
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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top