Hi,
Im trying to run a scenario analysis with VBA and have almost succeeded except for one small problem. The below macro runs scenarios for a dependent variable (T12), calculated in Calculator Worksheet, across each change in the independent variable (C5 to F5) however it only reports the result of the last iteration of independent variables (F5) shown in the row below (C6 to F6). Is there any way to change below code so that each scenario outcome (value of T12) is reported below the independent variable associated with it? In other words if T12 = 100 when Independent C5 is used then C6 shows 100 etc. Pls let me know if anything's unclear.
Thank you.
Sub ScenarioAnalysis()
Dim Independent(1 To 4) As Variant
Independent(1) = Worksheets("Scenario Analysis").Range("C5").Value
Independent(2) = Worksheets("Scenario Analysis").Range("D5").Value
Independent(3) = Worksheets("Scenario Analysis").Range("E5").Value
Independent(4) = Worksheets("Scenario Analysis").Range("F5").Value
For c = 1 To 4
Worksheets("Calculator").Range("E19") = Independent(c)
Worksheets("Scenario Analysis").Range("C6:F6") = Worksheets("Calculator").Range("T12")
Next
End Sub
Moderator Note:
Pls use code tags around your code next time as per forum rules.
Bookmarks