Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 95
Default summing ranges


Hi newsgroup,

I've got some problems with summing ranges, maybe someone
could give me a tip?

I have a range of 744 entries and I want to sum every 24
cells from the first cell of the range - this sum should
be written in another range which also has 744 entries -
so this second range should get the sum, then 23 empty
cells and then the sum of the next 24 cells from the first
range...

Now I'm thinking about a solution with modulo but
therefore I would need the cell index or something else...
but maybe someone knows a better solution? Nevertheless,
how can I relatively address a cell within a range?

Thanks a lot in advance.

Best regards!
Markus
..


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,236
Default summing ranges

Sub test()
Const cInterval = 24
Dim rngS As Range, rngD As Range, i As Long

Set rngS = Range("A1")
Set rngD = Range("C1")
For i = 0 To 744 - 1 Step cInterval
rngD.Offset(i).Value =
WorksheetFunction.Sum(rngS.Offset(i).Resize(cInter val))
Next
End Sub

--
Rob van Gelder - http://www.vangelder.co.nz/excel


"Markus Scheible" wrote in message
...

Hi newsgroup,

I've got some problems with summing ranges, maybe someone
could give me a tip?

I have a range of 744 entries and I want to sum every 24
cells from the first cell of the range - this sum should
be written in another range which also has 744 entries -
so this second range should get the sum, then 23 empty
cells and then the sum of the next 24 cells from the first
range...

Now I'm thinking about a solution with modulo but
therefore I would need the cell index or something else...
but maybe someone knows a better solution? Nevertheless,
how can I relatively address a cell within a range?

Thanks a lot in advance.

Best regards!
Markus
.




  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 95
Default summing ranges

Hi Rob,


Sub test()
Const cInterval = 24
Dim rngS As Range, rngD As Range, i As Long

Set rngS = Range("A1")
Set rngD = Range("C1")
For i = 0 To 744 - 1 Step cInterval
rngD.Offset(i).Value =
WorksheetFunction.Sum(rngS.Offset(i).Resize(cInte rval))
Next
End Sub



pretty good :o)

Thanks a lot and have a nice day!

Markus
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
summing to defined ranges keerthyV Excel Worksheet Functions 2 April 8th 09 08:05 AM
REF# error on summing ranges MLK Excel Worksheet Functions 2 November 12th 06 02:36 PM
Summing ranges Hru48 Excel Discussion (Misc queries) 1 May 11th 06 06:34 PM
summing non contiguous ranges valaor Excel Discussion (Misc queries) 6 March 22nd 06 04:17 PM
Summing ranges... Kevin Excel Programming 3 October 9th 03 09:19 PM


All times are GMT +1. The time now is 09:46 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"