Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 65
Default Sum Multiple Ranges

HI,

I have a 1 collumn which I have seperated in to ranges, of various lengths,
with 4 empty cells below each range I am trying to loop through and sum each
range on the 3rd cell below each range.

Thanks in Advance

Darren

--
Message posted via OfficeKB.com
http://www.officekb.com/Uwe/Forums.a...mming/200603/1
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 336
Default Sum Multiple Ranges

Here's one way (you have to select the whole column, excluding any headings
and down to the third cell below the final number group):

Sub mySum()
Dim myCounter As Long
Dim myTotal As Double
myTotal = 0
myCounter = 0
Do While myCounter <= Selection.Rows.Count
If ActiveCell.Offset(myCounter, 0).Value < "" Then
myTotal = myTotal + ActiveCell.Offset(myCounter, 0).Value
Else
ActiveCell.Offset(myCounter + 2, 0).Value = myTotal
myTotal = 0
myCounter = myCounter + 3
End If
myCounter = myCounter + 1
Loop
End Sub


"FIRSTROUNDKO via OfficeKB.com" wrote:

HI,

I have a 1 collumn which I have seperated in to ranges, of various lengths,
with 4 empty cells below each range I am trying to loop through and sum each
range on the 3rd cell below each range.

Thanks in Advance

Darren

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

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,092
Default Sum Multiple Ranges

Name your ranges rng1, rng 2 rng3, etc then use the following code:

Sub SumRngs()
Dim RngRows As Long
Dim c As String
Dim rngsum As Range
Dim cntr As Long

For cntr = 1 To 3
RngRows = Range("rng" & cntr).Rows.Count
c = Range("rng" & cntr).Address
Range(c).Range("A1").Offset(RngRows + 2, 0).Value =
WorksheetFunction.Sum(Range("rng" & cntr))
Next cntr
End Sub

MIke F

"FIRSTROUNDKO via OfficeKB.com" <u15639@uwe wrote in message
news:5d94e5ae8093b@uwe...
HI,

I have a 1 collumn which I have seperated in to ranges, of various
lengths,
with 4 empty cells below each range I am trying to loop through and sum
each
range on the 3rd cell below each range.

Thanks in Advance

Darren

--
Message posted via OfficeKB.com
http://www.officekb.com/Uwe/Forums.a...mming/200603/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
Can I create Multiple passwords to edit multiple ranges? Conker10382 Excel Discussion (Misc queries) 8 December 31st 06 07:58 PM
How do i update multiple data ranges across multiple worksheets? mwah Excel Discussion (Misc queries) 0 July 6th 06 04:57 AM
Crteating Multiple GIFS from Multiple Ranges -- need someone to test my code to see why it fails Father Guido[_5_] Excel Programming 4 November 22nd 05 05:28 AM
Crteating Multiple GIFS from Multiple Ranges -- need someone to test my code to see why it fails Father Guido[_5_] Excel Programming 0 November 19th 05 08:00 AM
Printing Multiple Ranges from Multiple Worksheets Dave Barkley[_2_] Excel Programming 1 July 22nd 03 06:10 PM


All times are GMT +1. The time now is 10:58 AM.

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"