Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Using an arrays to aggregate.

I am trying to aggregate a series of monthly cashflows using an array.
In my output I am only getting the very first run of cash flows (r=1)
as oppose to the total of the 5 runs. This needs to be done in VBA as
oppose to on a spreadsheet as ultimately this will be run 1,000 times
instead of 5.

Any thoughts?

Code Below

' Cash Flow aggregation

For r = 1 To 5
....
For i = 1 To 720
Term_CF(i) = Sheet4.Range("Monthly_Term").Cells(i,
1).Value
Term_Total(i) = Term_Total(i) + Term_CF(i)
MIP_CF(i) = Sheet4.Range("Monthly_MIP").Cells(i, 1).Value
MIP_Total(i) = MIP_Total(i) + MIP_CF(i)
Next i

Next r

For i = 1 To 720
Sheet10.Range("CashFlow_Term").Cells(i, 1).Value =
Val(Term_Total(i))
Sheet10.Range("CashFlow_MIP").Cells(i, 1).Value =
Val(MIP_Total(i))
Next i

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 56
Default Using an arrays to aggregate.

I think I need to se miore of your code to answer this - I can see where you
are dimming your arrays etc.

Also I am a bit lost as to why you have the "r" loop as r doesnt seem to be
reference anywhere within the loop (just one of those test harness things I
guess?)


ttfn benm
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Using an arrays to aggregate.

Assume your data is in A1:E720 in sheet Monthly_Term then

Code Below

' Cash Flow aggregation

For r = 1 To 5
....
For i = 1 To 720
Term_CF(i) = Sheet4.Range("Monthly_Term").Cells(i,r).Value
Term_Total(i) = Term_Total(i) + Term_CF(i)
MIP_CF(i) = Sheet4.Range("Monthly_MIP").Cells(i, r).Value
MIP_Total(i) = MIP_Total(i) + MIP_CF(i)
Next i

Next r

For i = 1 To 720
Sheet10.Range("CashFlow_Term").Cells(i, 1).Value =
Val(Term_Total(i))
Sheet10.Range("CashFlow_MIP").Cells(i, 1).Value =
Val(MIP_Total(i))
Next i

--
Regards,
Tom Ogilvy

wrote in message
oups.com...
I am trying to aggregate a series of monthly cashflows using an array.
In my output I am only getting the very first run of cash flows (r=1)
as oppose to the total of the 5 runs. This needs to be done in VBA as
oppose to on a spreadsheet as ultimately this will be run 1,000 times
instead of 5.

Any thoughts?

Code Below

' Cash Flow aggregation

For r = 1 To 5
...
For i = 1 To 720
Term_CF(i) = Sheet4.Range("Monthly_Term").Cells(i,
1).Value
Term_Total(i) = Term_Total(i) + Term_CF(i)
MIP_CF(i) = Sheet4.Range("Monthly_MIP").Cells(i, 1).Value
MIP_Total(i) = MIP_Total(i) + MIP_CF(i)
Next i

Next r

For i = 1 To 720
Sheet10.Range("CashFlow_Term").Cells(i, 1).Value =
Val(Term_Total(i))
Sheet10.Range("CashFlow_MIP").Cells(i, 1).Value =
Val(MIP_Total(i))
Next i



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
Aggregate tables nc Excel Discussion (Misc queries) 0 September 12th 08 03:35 PM
how do I aggregate dates Johnopp Excel Discussion (Misc queries) 5 March 5th 06 10:26 PM
Aggregate function stefantem[_17_] Excel Programming 2 January 19th 06 08:47 AM
aggregate calculations [email protected] Excel Discussion (Misc queries) 0 May 26th 05 04:32 PM
How to aggregate in Excel? Frank Krogh Excel Programming 1 March 4th 04 02:31 PM


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