Hi! I am trying to use LEAP's script editor to import data from a xlsx file. This data would be valid only for a specific scenario ("Reference Scenario"), so I tried to do the following:
firstscenario_year = LEAP.FirstScenarioYear - 2
end_year = LEAP.EndYear
LEAP.Scenario("Reference Scenario").Active = TRUE
Set Residential = LEAP.Branches("Demand").Children("Residential").Children("Charcoal")
Set var_activity_level = Residential.Variable("Total Energy")
Dim year
result_expression = "Step("
For year = firstscenario_year To end_year
if ( year > firstscenario_year ) Then
result_expression = result_expression & ", "
end if
result_expression = result_expression & sheet_resultado.Cells(2,year-firstscenario_year+4).Value
result_expression = result_expression & ", " & sheet_resultado.Cells(3,year-firstscenario_year+4).Value
Next
result_expression = result_expression & ")"
var_activity_level.Expression = result_expression
My problem is in the line in bold above. It is not selecting the scenario "Reference Scenario". In fact, LEAP is always filling the scenario I select before running this code (for example, if I am in the current accounts scenario, then data from the excel is pasted in Current Accounts, not in "Reference Scenario"). I have also tried to use LEAP.ActiveScenario = "Reference Scenario" and LEAP.ActiveScenario = LEAP.Scenarios("Reference Scenario"), with the same result.