I have an Excel model used to create cashflows from real estate projects.
Rather than calculate cashflows for all units within a property simultaneously on a "live" basis with formulas, the model uses a "roll-up" which calculates the cashflow for a single unit at a time then uses VBA to loop through each unit, copying the cashflow for that unit to another part of the tab as values only. It then loops through all remaining units, using Paste-Special-Add such that by the time the loop is exited, I have the aggregate cashflow for the entire property (i.e. all unit cashflows added together).
This approach works fine but, via work on another project, I have recently had my eyes opened to the speed benefits of minimizing copy and paste actions by using array variables instead and then "dumping" the contents of an array to a range all in one go.
I can follow the code for these operations fine.
My query is how best to adopt the array variable approach when trying to add values rather than just taking them from one place to another?
I can set up 2 arrays, one to receive the unit cashflow and the other to act as the running total. But for that to work, do I have to cycle through each element of the array adding the new elements to the respective individual running totals?
Or is there a way to simply add ALL elements in one array to all elements in another? Both arrays would be the same size.
From other material I have read here and elsewhere, I can happily create the code to dump the end result to a range.
Many thanks for any pointers.
Bookmarks