V
velocityinc
Says variable not defined for number of trials for some reason - any
way to correct this?
Private Sub MyFunction()
' this variable holds the number of trials in the simulation
NumberOfTrials = 500
' start the simulation with the desired number of trials
RiskAMP_BeginSteppedSimulation (NumberOfTrials)
' use a loop to run the simulation for the same number of trials
For i = 1 To NumberOfTrials
' any VBA code can be run here; in this example, we do
' a simple calculation on some spreadsheet values.
Sheets("Interest").Select
Range("E28I28").Select
Selection.Copy
Range("E29").Select
Range(Selection, Selection.End(xlDown)).Select
Selection.PasteSpecial Paste:=xlPasteAll, Operation:=xlNone,
SkipBlanks:= _
False, Transpose:=False
Application.CutCopyMode = False
Selection.Copy
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
SkipBlanks _
:=False, Transpose:=False
Range("G5").Select
ActiveCell.FormulaR1C1 = "=NOW()"
Selection.Copy
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
SkipBlanks _
:=False, Transpose:=False
Sheets("Principal").Select
Range("E28I28").Select
Selection.Copy
Range("E29").Select
Range(Selection, Selection.End(xlDown)).Select
Selection.PasteSpecial Paste:=xlPasteAll, Operation:=xlNone,
SkipBlanks:= _
False, Transpose:=False
Application.CutCopyMode = False
Selection.Copy
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
SkipBlanks _
:=False, Transpose:=False
Range("G5").Select
ActiveCell.FormulaR1C1 = "=NOW()"
Selection.Copy
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
SkipBlanks _
:=False, Transpose:=False
Sheets("Leasing Analysis").Select
Range("A2").Select
' this call advances the simulation by one trial
RiskAMP_IterateSimulationStep
Next i
' when the loop is complete, finish the simulation
RiskAMP_FinishSteppedSimulation
End Sub
way to correct this?
Private Sub MyFunction()
' this variable holds the number of trials in the simulation
NumberOfTrials = 500
' start the simulation with the desired number of trials
RiskAMP_BeginSteppedSimulation (NumberOfTrials)
' use a loop to run the simulation for the same number of trials
For i = 1 To NumberOfTrials
' any VBA code can be run here; in this example, we do
' a simple calculation on some spreadsheet values.
Sheets("Interest").Select
Range("E28I28").Select
Selection.Copy
Range("E29").Select
Range(Selection, Selection.End(xlDown)).Select
Selection.PasteSpecial Paste:=xlPasteAll, Operation:=xlNone,
SkipBlanks:= _
False, Transpose:=False
Application.CutCopyMode = False
Selection.Copy
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
SkipBlanks _
:=False, Transpose:=False
Range("G5").Select
ActiveCell.FormulaR1C1 = "=NOW()"
Selection.Copy
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
SkipBlanks _
:=False, Transpose:=False
Sheets("Principal").Select
Range("E28I28").Select
Selection.Copy
Range("E29").Select
Range(Selection, Selection.End(xlDown)).Select
Selection.PasteSpecial Paste:=xlPasteAll, Operation:=xlNone,
SkipBlanks:= _
False, Transpose:=False
Application.CutCopyMode = False
Selection.Copy
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
SkipBlanks _
:=False, Transpose:=False
Range("G5").Select
ActiveCell.FormulaR1C1 = "=NOW()"
Selection.Copy
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
SkipBlanks _
:=False, Transpose:=False
Sheets("Leasing Analysis").Select
Range("A2").Select
' this call advances the simulation by one trial
RiskAMP_IterateSimulationStep
Next i
' when the loop is complete, finish the simulation
RiskAMP_FinishSteppedSimulation
End Sub