I have a macro which runs the same thing 1000 times with change in the inputs. Here's the code:

Sub valgen()

Application.Screenupdating = False

Dim RateArr(), DfArr() As Double

Dim TempArr1(), TempArr2() As Variant

Dim i As Integer

ReDim RateArr(1 To 50, 1 To 77)

ReDim DfArr(1 To 50, 1 To 154)

ReDim TempArr1(1 To 50)

ReDim TempArr2(1 To 50)

For i = 2 To 1000

Range("C1195").Select

ActiveCell.Offset(4 * (i - 2), 0).Select

ActiveCell.Value = "SCENARIO" & " " & i

Range(ActiveCell.Offset(0, 2), ActiveCell.Offset(0, 78)).Value = Range(ActiveCell.Offset((-3 * i - 1114), 2), ActiveCell.Offset((-3 * i - 1114), 78)).Value

RateArr = forwardlibor(Range("D5", "CB64"), Range("A1079", "A1128"), Range("B1079", "B1128"), Range("D1078", "CB1078"), 1, Range(ActiveCell.Offset(0, 2), ActiveCell.Offset(0, 78)))

DfArr = CurveGen(Range("D1078", "CB1078"), RateArr)

'Range(ActiveCell.Offset(2, 1), ActiveCell.Offset(52, 155)).Value

For j = 1 To 77

TempArr1 = Application.Index(DfArr, 0, (2 * j - 1))

TempArr2 = Application.Index(DfArr, 0, 2 * j)

ActiveCell.Offset(2, j - 1).Value = FIXLEG(Range("B1162").Value, Range("B1164").Value, Range("B1165").Value, Range("B1166").Value, Range("B1167").Value, Range("B1168").Value, TempArr1, TempArr2) - FLTLEG(Range("B1178").Value, Range("B1179").Value, Range("B1180").Value, Range("B1181").Value, Range("B1182").Value, Range("B1183").Value, Range("B1184").Value, TempArr1, TempArr2)

Next

Next

Application.Screenupdating = True

End Sub

It is taking around 20 minutes to run! Is there a way to speed it up??Application.Screenupdating = False

Dim RateArr(), DfArr() As Double

Dim TempArr1(), TempArr2() As Variant

Dim i As Integer

ReDim RateArr(1 To 50, 1 To 77)

ReDim DfArr(1 To 50, 1 To 154)

ReDim TempArr1(1 To 50)

ReDim TempArr2(1 To 50)

For i = 2 To 1000

Range("C1195").Select

ActiveCell.Offset(4 * (i - 2), 0).Select

ActiveCell.Value = "SCENARIO" & " " & i

Range(ActiveCell.Offset(0, 2), ActiveCell.Offset(0, 78)).Value = Range(ActiveCell.Offset((-3 * i - 1114), 2), ActiveCell.Offset((-3 * i - 1114), 78)).Value

RateArr = forwardlibor(Range("D5", "CB64"), Range("A1079", "A1128"), Range("B1079", "B1128"), Range("D1078", "CB1078"), 1, Range(ActiveCell.Offset(0, 2), ActiveCell.Offset(0, 78)))

DfArr = CurveGen(Range("D1078", "CB1078"), RateArr)

'Range(ActiveCell.Offset(2, 1), ActiveCell.Offset(52, 155)).Value

For j = 1 To 77

TempArr1 = Application.Index(DfArr, 0, (2 * j - 1))

TempArr2 = Application.Index(DfArr, 0, 2 * j)

ActiveCell.Offset(2, j - 1).Value = FIXLEG(Range("B1162").Value, Range("B1164").Value, Range("B1165").Value, Range("B1166").Value, Range("B1167").Value, Range("B1168").Value, TempArr1, TempArr2) - FLTLEG(Range("B1178").Value, Range("B1179").Value, Range("B1180").Value, Range("B1181").Value, Range("B1182").Value, Range("B1183").Value, Range("B1184").Value, TempArr1, TempArr2)

Next

Next

Application.Screenupdating = True

End Sub

Last edited: