Recovery Curve VBA Code help to reduce repetitive Parts

dariushou

Board Regular
Joined
Feb 17, 2008
Messages
126
HI Everyone,

I have some vba code that I’ve been using for years that I use to project the recoveries of an asset over some period of time according to a vector. So if I have cash outlay in period 1, I have a curve that recovers that cash amount over some period time (let’s say 24 months). In period 1, I would multiply the first value in the 24 month vector by the initial cash amount so that 100% is recovered in month 24. If there is another cash outlay in period 2 then that cash would also be recovered according to the same curve. So in period 2, you multiply the Cash Amount from Period 1 by the 2nd value in the vector…then the Cash Amount from Period 2 would be multiplied by the 1st value in the vector and so forth.

This code works perfect for that. The issue is the code can become very cumbersome. I’m hoping someone can help me reduce the repetitive parts of the code…I’m about to have 100s of different curves and cash amounts so typing in 100 different arrays is going to be painful.

I can't seem to be able to attach the spreadsheet. In its current form the spreadsheet just has 5 recovery curves and asset amounts. All of the recovery curves are next to each other. The cash amounts are in columns next to those and the results are printed in the columns to the right of the cash amounts. So 1st 5 columns are the recovery curves, next 5 columns represent different types of cash flows that occur in each period. (the curves start in column B – I reserve the first column for the Month so in row 7, column A, is “1”, in the next row in column A is the number “2”…so 1,2,3,4…

Code:
Sub Recovery()
    
    Dim myArray
    Dim cfArray1() As Double: Dim cfArray2() As Double: Dim cfArray3() As Double
    Dim cfArray4() As Double: Dim cfArray5() As Double
    Dim fr As Long: Dim lr As Long: Dim X As Long: Dim i As Long: Dim p As Long
    Dim C1 As Long: Dim C2 As Long
  
    Application.ScreenUpdating = False
    Application.EnableEvents = False
    
    fr = 7 'first data row
    lr = 500 'last row of data
    C1 = 2 '1st column of recovery curves (first column is for Months/Period so row 7 = period 1; Row 8 = Period 2, etc...)
    C2 = 7 '1st column of assets
    
    
    myArray = Worksheets("Recovery").Range("A1:P" & lr).Value


    ReDim cfArray1(fr To lr, 1): ReDim cfArray2(fr To lr, 1): ReDim cfArray3(fr To lr, 1)
    ReDim cfArray4(fr To lr, 1): ReDim cfArray5(fr To lr, 1)
    
    For X = fr To lr
        p = fr
        For i = X To X - (lr - fr + 1) Step -1
            If i < fr Then Exit For
            
            cfArray1(X, 0) = cfArray1(X, 0) + myArray(i, C1 + 0) * myArray(p, C2 + 0)
            cfArray2(X, 0) = cfArray2(X, 0) + myArray(i, C1 + 1) * myArray(p, C2 + 1)
            cfArray3(X, 0) = cfArray3(X, 0) + myArray(i, C1 + 2) * myArray(p, C2 + 2)
            cfArray4(X, 0) = cfArray4(X, 0) + myArray(i, C1 + 3) * myArray(p, C2 + 3)
            cfArray5(X, 0) = cfArray5(X, 0) + myArray(i, C1 + 4) * myArray(p, C2 + 4)
            
            p = p + 1
        Next i
    Next X
    
    Worksheets("Recovery").Cells(fr, "L").Resize(UBound(cfArray1, 1) - LBound(cfArray1, 1) + 1) = cfArray1
    Worksheets("Recovery").Cells(fr, "M").Resize(UBound(cfArray2, 1) - LBound(cfArray2, 1) + 1) = cfArray2
    Worksheets("Recovery").Cells(fr, "N").Resize(UBound(cfArray3, 1) - LBound(cfArray3, 1) + 1) = cfArray3
    Worksheets("Recovery").Cells(fr, "O").Resize(UBound(cfArray4, 1) - LBound(cfArray4, 1) + 1) = cfArray4
    Worksheets("Recovery").Cells(fr, "P").Resize(UBound(cfArray5, 1) - LBound(cfArray5, 1) + 1) = cfArray5


    Application.EnableEvents = True
    Application.ScreenUpdating = True


End Sub
 
Last edited by a moderator:

Excel Facts

Excel Wisdom
Using a mouse in Excel is the work equivalent of wearing a lanyard when you first get to college
I couldn't attached the spreadsheet, but here is the data in excel in table format. the data starts on row 7 so Month 1 is row 7.

[TABLE="width: 500"]
<tbody>[TR]
[TD][TABLE="width: 1478"]
<tbody>[TR]
[TD]Totals[/TD]
[TD="align: right"]100.00%[/TD]
[TD="align: right"]100.00%[/TD]
[TD="align: right"]100.00%[/TD]
[TD="align: right"]100.00%[/TD]
[TD="align: right"]100.00%[/TD]
[TD] 888,109[/TD]
[TD] 222,027[/TD]
[TD] 1,110,136[/TD]
[TD] 1,332,164[/TD]
[TD] 417,411[/TD]
[TD] 888,109[/TD]
[TD] 222,027[/TD]
[TD] 1,110,136[/TD]
[TD] 1,332,164[/TD]
[TD] 417,411[/TD]
[/TR]
[TR]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]Month[/TD]
[TD]Curve 1[/TD]
[TD]Curve 2[/TD]
[TD]Curve 3[/TD]
[TD]Curve 4[/TD]
[TD]Curve 5[/TD]
[TD]Assets 1[/TD]
[TD]Assets 2[/TD]
[TD]Assets 3[/TD]
[TD]Assets 4[/TD]
[TD]Assets 5[/TD]
[TD]Recovery 1[/TD]
[TD]Recovery 2[/TD]
[TD]Recovery 3[/TD]
[TD]Recovery 4[/TD]
[TD]Recovery 5[/TD]
[/TR]
[TR]
[TD="align: right"]1[/TD]
[TD="align: right"]6.0000%[/TD]
[TD="align: right"]16.0000%[/TD]
[TD="align: right"]24.0000%[/TD]
[TD="align: right"]2.0000%[/TD]
[TD="align: right"]4.5000%[/TD]
[TD] 25,000[/TD]
[TD] 6,250[/TD]
[TD] 31,250[/TD]
[TD] 37,500[/TD]
[TD] 11,750[/TD]
[TD] 1,500.00[/TD]
[TD] 1,000.00[/TD]
[TD] 7,500.00[/TD]
[TD] 750.00[/TD]
[TD] 528.75[/TD]
[/TR]
[TR]
[TD="align: right"]2[/TD]
[TD="align: right"]3.0000%[/TD]
[TD="align: right"]2.0000%[/TD]
[TD="align: right"]1.0000%[/TD]
[TD="align: right"]3.2000%[/TD]
[TD="align: right"]2.9500%[/TD]
[TD] 35,000[/TD]
[TD] 8,750[/TD]
[TD] 43,750[/TD]
[TD] 52,500[/TD]
[TD] 16,450[/TD]
[TD] 2,850.00[/TD]
[TD] 1,525.00[/TD]
[TD] 10,812.50[/TD]
[TD] 2,250.00[/TD]
[TD] 1,086.88[/TD]
[/TR]
[TR]
[TD="align: right"]3[/TD]
[TD="align: right"]4.0000%[/TD]
[TD="align: right"]3.0000%[/TD]
[TD="align: right"]2.0000%[/TD]
[TD="align: right"]4.2000%[/TD]
[TD="align: right"]3.9500%[/TD]
[TD] 14,000[/TD]
[TD] 3,500[/TD]
[TD] 17,500[/TD]
[TD] 21,000[/TD]
[TD] 6,580[/TD]
[TD] 2,890.00[/TD]
[TD] 922.50[/TD]
[TD] 5,262.50[/TD]
[TD] 3,675.00[/TD]
[TD] 1,245.50[/TD]
[/TR]
[TR]
[TD="align: right"]4[/TD]
[TD="align: right"]5.0000%[/TD]
[TD="align: right"]4.0000%[/TD]
[TD="align: right"]3.0000%[/TD]
[TD="align: right"]5.2000%[/TD]
[TD="align: right"]4.9500%[/TD]
[TD] 10,000[/TD]
[TD] 2,500[/TD]
[TD] 12,500[/TD]
[TD] 15,000[/TD]
[TD] 4,700[/TD]
[TD] 3,670.00[/TD]
[TD] 982.50[/TD]
[TD] 4,987.50[/TD]
[TD] 5,127.00[/TD]
[TD] 1,637.01[/TD]
[/TR]
[TR]
[TD="align: right"]5[/TD]
[TD="align: right"]2.0000%[/TD]
[TD="align: right"]1.0000%[/TD]
[TD="align: right"]0.0000%[/TD]
[TD="align: right"]2.2000%[/TD]
[TD="align: right"]1.9500%[/TD]
[TD] 50,000[/TD]
[TD] 12,500[/TD]
[TD] 62,500[/TD]
[TD] 75,000[/TD]
[TD] 23,500[/TD]
[TD] 6,110.00[/TD]
[TD] 2,567.50[/TD]
[TD] 16,787.50[/TD]
[TD] 6,417.00[/TD]
[TD] 2,499.46[/TD]
[/TR]
[TR]
[TD="align: right"]6[/TD]
[TD="align: right"]1.0000%[/TD]
[TD="align: right"]0.0000%[/TD]
[TD="align: right"]1.0000%[/TD]
[TD="align: right"]3.2000%[/TD]
[TD="align: right"]2.9500%[/TD]
[TD] 125,000[/TD]
[TD] 31,250[/TD]
[TD] 156,250[/TD]
[TD] 187,500[/TD]
[TD] 58,750[/TD]
[TD] 11,050.00[/TD]
[TD] 5,552.50[/TD]
[TD] 39,212.50[/TD]
[TD] 10,227.00[/TD]
[TD] 4,515.76[/TD]
[/TR]
[TR]
[TD="align: right"]7[/TD]
[TD="align: right"]8.0000%[/TD]
[TD="align: right"]7.0000%[/TD]
[TD="align: right"]6.0000%[/TD]
[TD="align: right"]8.2000%[/TD]
[TD="align: right"]7.9500%[/TD]
[TD] 350,000[/TD]
[TD] 87,500[/TD]
[TD] 437,500[/TD]
[TD] 525,000[/TD]
[TD] 164,500[/TD]
[TD] 29,880.00[/TD]
[TD] 15,572.50[/TD]
[TD] 110,500.00[/TD]
[TD] 25,647.00[/TD]
[TD] 11,844.24[/TD]
[/TR]
[TR]
[TD="align: right"]8[/TD]
[TD="align: right"]12.0000%[/TD]
[TD="align: right"]11.0000%[/TD]
[TD="align: right"]10.0000%[/TD]
[TD="align: right"]12.2000%[/TD]
[TD="align: right"]11.9500%[/TD]
[TD] 24,000[/TD]
[TD] 6,000[/TD]
[TD] 30,000[/TD]
[TD] 36,000[/TD]
[TD] 11,280[/TD]
[TD] 25,580.00[/TD]
[TD] 5,472.50[/TD]
[TD] 22,500.00[/TD]
[TD] 39,177.00[/TD]
[TD] 11,841.89[/TD]
[/TR]
[TR]
[TD="align: right"]9[/TD]
[TD="align: right"]13.0000%[/TD]
[TD="align: right"]12.0000%[/TD]
[TD="align: right"]11.0000%[/TD]
[TD="align: right"]13.2000%[/TD]
[TD="align: right"]12.9500%[/TD]
[TD] 69,000[/TD]
[TD] 17,250[/TD]
[TD] 86,250[/TD]
[TD] 103,500[/TD]
[TD] 32,430[/TD]
[TD] 34,780.00[/TD]
[TD] 8,837.50[/TD]
[TD] 43,425.00[/TD]
[TD] 50,229.00[/TD]
[TD] 15,805.40[/TD]
[/TR]
[TR]
[TD="align: right"]10[/TD]
[TD="align: right"]25.0000%[/TD]
[TD="align: right"]24.0000%[/TD]
[TD="align: right"]23.0000%[/TD]
[TD="align: right"]25.2000%[/TD]
[TD="align: right"]24.9500%[/TD]
[TD] 88,888[/TD]
[TD] 22,222[/TD]
[TD] 111,110[/TD]
[TD] 133,332[/TD]
[TD] 41,777[/TD]
[TD] 42,143.28[/TD]
[TD] 11,003.02[/TD]
[TD] 56,378.90[/TD]
[TD] 61,487.64[/TD]
[TD] 19,485.71[/TD]
[/TR]
[TR]
[TD="align: right"]11[/TD]
[TD="align: right"]21.0000%[/TD]
[TD="align: right"]20.0000%[/TD]
[TD="align: right"]19.0000%[/TD]
[TD="align: right"]21.2000%[/TD]
[TD="align: right"]20.9500%[/TD]
[TD] 7,777[/TD]
[TD] 1,944[/TD]
[TD] 9,721[/TD]
[TD] 11,666[/TD]
[TD] 3,655[/TD]
[TD] 36,363.26[/TD]
[TD] 7,308.02[/TD]
[TD] 30,556.70[/TD]
[TD] 60,200.93[/TD]
[TD] 18,025.05[/TD]
[/TR]
[TR]
[TD="align: right"]12[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD] 444[/TD]
[TD] 111[/TD]
[TD] 555[/TD]
[TD] 666[/TD]
[TD] 209[/TD]
[TD] 39,395.47[/TD]
[TD] 7,925.81[/TD]
[TD] 38,752.61[/TD]
[TD] 71,887.56[/TD]
[TD] 21,620.93[/TD]
[/TR]
[TR]
[TD="align: right"]13[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD] 25,000[/TD]
[TD] 6,250[/TD]
[TD] 31,250[/TD]
[TD] 37,500[/TD]
[TD] 11,750[/TD]
[TD] 62,828.80[/TD]
[TD] 14,484.43[/TD]
[TD] 66,283.28[/TD]
[TD] 95,680.53[/TD]
[TD] 29,405.20[/TD]
[/TR]
[TR]
[TD="align: right"]14[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD] 50,000[/TD]
[TD] 12,500[/TD]
[TD] 62,500[/TD]
[TD] 75,000[/TD]
[TD] 23,500[/TD]
[TD] 81,394.37[/TD]
[TD] 19,723.32[/TD]
[TD] 95,965.24[/TD]
[TD] 123,411.88[/TD]
[TD] 38,375.18[/TD]
[/TR]
[TR]
[TD="align: right"]15[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD] 14,000[/TD]
[TD] 3,500[/TD]
[TD] 17,500[/TD]
[TD] 21,000[/TD]
[TD] 6,580[/TD]
[TD] 100,056.62[/TD]
[TD] 23,388.88[/TD]
[TD] 110,690.25[/TD]
[TD] 154,281.90[/TD]
[TD] 47,577.78[/TD]
[/TR]
[TR]
[TD="align: right"]16[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD] 136,017.69[/TD]
[TD] 32,119.15[/TD]
[TD] 151,363.81[/TD]
[TD] 206,522.17[/TD]
[TD] 63,824.20[/TD]
[/TR]
[TR]
[TD="align: right"]17[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD] 103,323.16[/TD]
[TD] 24,258.02[/TD]
[TD] 113,437.33[/TD]
[TD] 156,885.39[/TD]
[TD] 48,418.22[/TD]
[/TR]
[TR]
[TD="align: right"]18[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD] 36,764.20[/TD]
[TD] 8,493.28[/TD]
[TD] 39,602.53[/TD]
[TD] 56,733.63[/TD]
[TD] 17,448.58[/TD]
[/TR]
[TR]
[TD="align: right"]19[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD] 40,556.29[/TD]
[TD] 9,501.30[/TD]
[TD] 45,567.64[/TD]
[TD] 63,099.76[/TD]
[TD] 19,471.51[/TD]
[/TR]
[TR]
[TD="align: right"]20[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD] 27,808.45[/TD]
[TD] 6,486.84[/TD]
[TD] 30,457.84[/TD]
[TD] 42,691.00[/TD]
[TD] 13,157.84[/TD]
[/TR]
[TR]
[TD="align: right"]21[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD] 12,114.17[/TD]
[TD] 2,785.49[/TD]
[TD] 12,712.19[/TD]
[TD] 18,462.92[/TD]
[TD] 5,670.81[/TD]
[/TR]
[TR]
[TD="align: right"]22[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD] 14,523.24[/TD]
[TD] 3,407.20[/TD]
[TD] 15,917.95[/TD]
[TD] 22,053.19[/TD]
[TD] 6,804.90[/TD]
[/TR]
[TR]
[TD="align: right"]23[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD] 19,570.00[/TD]
[TD] 4,670.00[/TD]
[TD] 22,237.50[/TD]
[TD] 29,622.00[/TD]
[TD] 9,176.99[/TD]
[/TR]
[TR]
[TD="align: right"]24[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD] 14,000.00[/TD]
[TD] 3,340.00[/TD]
[TD] 15,900.00[/TD]
[TD] 21,192.00[/TD]
[TD] 6,564.96[/TD]
[/TR]
[TR]
[TD="align: right"]25[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD] 2,940.00[/TD]
[TD] 700.00[/TD]
[TD] 3,325.00[/TD]
[TD] 4,452.00[/TD]
[TD] 1,378.51[/TD]
[/TR]
</tbody>[/TABLE]
[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
</tbody>[/TABLE]
 
Upvote 0
Any help on this. My big issue is the below code. Just can't seem to figure out the right way to only have one cfArray variable instead of 5. I would think this could be done in a for loop, but i've failed miserable at trying to figure it out.

Thanks,
Darius

Code:
cfArray1(X, 0) = cfArray1(X, 0) + myArray(i, C1 + 0) * myArray(p, C2 + 0)
cfArray2(X, 0) = cfArray2(X, 0) + myArray(i, C1 + 1) * myArray(p, C2 + 1)
cfArray3(X, 0) = cfArray3(X, 0) + myArray(i, C1 + 2) * myArray(p, C2 + 2)
cfArray4(X, 0) = cfArray4(X, 0) + myArray(i, C1 + 3) * myArray(p, C2 + 3)
cfArray5(X, 0) = cfArray5(X, 0) + myArray(i, C1 + 4) * myArray(p, C2 + 4)
 
Upvote 0

Forum statistics

Threads
1,223,893
Messages
6,175,240
Members
452,621
Latest member
Laura_PinksBTHFT

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top