Excel is a dangerous tool I think!
Not as dangerous as some of the tools who use it
The below prevents unnecessary re-calculation and, most importantly no rendering to screen – which *should* speed things significantly.
It’s annoying how the indentation will be lost here…
Option Explicit
Sub Test()
Dim i As Integer, NPV As Integer, AMP6 As Integer, AMP7 As Integer, AMP8 As Integer
With Application
.ScreenUpdating = False
Calc_Man
For i = 2 To 5000
‘Select the data from the calculation sheet
With Sheets(“Catchment solution”)
.Calculate
NPV = .Range(“c154”).Value
AMP6 = .Range(“c155”).Value
AMP7 = .Range(“c156”).Value
AMP8 = .Range(“c157”).Value
End With
‘Paste the data for use in the percentile calculation
With Sheets(“Monte Carlo Model”)
.Cells(i, 1).Value = NPV
.Cells(i, 2).Value = AMP6
.Cells(i, 3).Value = AMP7
.Cells(i, 4).Value = AMP8
End With
Next i
Calc_Auto
.ScreenUpdating = True
End With
End Sub
Sub Calc_Man()
‘Turns on manual calculation’
With Application
.Calculation = xlManual
.MaxChange = 0.001
End With
ActiveWorkbook.PrecisionAsDisplayed = False
End Sub
Sub Calc_Auto()
‘Turns on auto calculation’
With Application
.Calculation = xlAutomatic
.MaxChange = 0.001
End With
ActiveWorkbook.PrecisionAsDisplayed = False
End Sub