Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default 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.

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 59
Default 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.



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5
Default 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

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Adding sums in rows and columns and colouring cells with condition Manosh Excel Discussion (Misc queries) 2 June 4th 09 06:09 AM
Fill Cells with same number in three rows then skip to next number Tracy Excel Worksheet Functions 2 November 7th 08 03:12 PM
formula that sums cells yet does not round the number up or down. cioangel Excel Worksheet Functions 4 October 30th 06 08:50 PM
Setting varible to equal values of a # of cells mozart[_8_] Excel Programming 6 April 15th 06 11:32 PM
Excel VBA - Varible number rows louismx Excel Programming 2 May 30th 04 03:23 AM


All times are GMT +1. The time now is 07:30 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"