Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 183
Default sum values in multiple ranges

in the following code, I am not too sure how to add the cell values in the
defined ranges.
I want each cell in range Addt(j) to equal the sum of cell in range Plus(j)
and this for each N value.

Thanks in advance

Dim Addt(1 To 3) As Range
Set Addt(1) = Range(Range("Region1").Offset( 1,
2), Range("Region1").Offset( 1, 9))
Set Addt(2) = Range(Range("Region1").Offset( 4,
2), Range("Region1").Offset( 4, 9))
Set Addt(3) = Range(Range("Region1").Offset( 8,
2), Range("Region1").Offset( 8, 9))


For j = 1 To UBound(Addt)
For N = 48 to 56

Dim Plus(1 To 3) As Range
Set Plus(1) = Range(Range("Country1").Offset(N +
1, 2), Range("Country1").Offset(N + 1, 9))
Set Plus(2) = Range(Range("Country1").Offset(N +
4, 2), Range("Country1").Offset(N + 4, 9))
Set Plus(3) = Range(Range("Country1").Offset(N +
8, 2), Range("Country1").Offset(N + 8, 9))


How can I write this formula?
Addt(j).value =Addt(j).Value+ Plus(j).Value

next
next
--
caroline
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9,101
Default sum values in multiple ranges

See if this works.


Sub test()
Dim Plus() As Variant
Dim Addt() As Variant
AddRows = Array(1, 4, 8)

ReDim Addt(UBound(AddRows))
ReDim Plus(UBound(AddRows))
For J = 1 To UBound(AddRows)
Set Addt(J) = Range(Range("Region1") _
.Offset(AddRows(J), 2), Range("Region1").Offset(AddRows(J), 9))
For N = 48 To 56
Set Plus(J) = Range( _
Range("Country1").Offset(N + AddRows(J), 2), _
Range("Country1").Offset(N + AddRows(J), 9))
Next N
For ColOffset = 0 To (Addt(J).Columns.Count - 1)
Addt(J)(0, ColOffset) = Addt(J)(0, ColOffset) + _
WorksheetFunction.Sum(Plus(J))

Next ColOffset

Next J

End Sub

"caroline" wrote:

in the following code, I am not too sure how to add the cell values in the
defined ranges.
I want each cell in range Addt(j) to equal the sum of cell in range Plus(j)
and this for each N value.

Thanks in advance

Dim Addt(1 To 3) As Range
Set Addt(1) = Range(Range("Region1").Offset( 1,
2), Range("Region1").Offset( 1, 9))
Set Addt(2) = Range(Range("Region1").Offset( 4,
2), Range("Region1").Offset( 4, 9))
Set Addt(3) = Range(Range("Region1").Offset( 8,
2), Range("Region1").Offset( 8, 9))


For j = 1 To UBound(Addt)
For N = 48 to 56

Dim Plus(1 To 3) As Range
Set Plus(1) = Range(Range("Country1").Offset(N +
1, 2), Range("Country1").Offset(N + 1, 9))
Set Plus(2) = Range(Range("Country1").Offset(N +
4, 2), Range("Country1").Offset(N + 4, 9))
Set Plus(3) = Range(Range("Country1").Offset(N +
8, 2), Range("Country1").Offset(N + 8, 9))


How can I write this formula?
Addt(j).value =Addt(j).Value+ Plus(j).Value

next
next
--
caroline

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
Averaging multiple ranges with #n/a values Anne Excel Discussion (Misc queries) 0 August 13th 08 05:20 PM
sum the values of a range based upon multiple ranges and criteria LiveIt... Excel Worksheet Functions 1 July 17th 06 09:23 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


All times are GMT +1. The time now is 01:08 AM.

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

About Us

"It's about Microsoft Excel"