Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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("E28:DI28").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("E28:DI28").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 |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
How do I acess the printer variable "number of copies"? | Excel Worksheet Functions | |||
How do I access the printer variable "number of copies"? | Excel Worksheet Functions | |||
"Variable not defined" error for form that does not initially exist... | Excel Programming | |||
use variable in Workbooks("book1").Worksheets("sheet1").Range("a1" | Excel Programming |