Reputation: 1139
I am trying to loop through a named range in Excel and set its value equal to another named range that is dynamic in value (called SensitivityResults
). How do I get Excel to essentially say:
Range("Scenario1").Value = Range("SensitivityResults").Value
Range("Scenario2").Value = Range("SensitivityResults").Value
Range("Scenario2").Value = Range("SensitivityResults").Value
etc...
My code as follows does not work:
Dim i As Integer
Dim s As Integer
For i = 1 To 20
For s = 1 To 20
Range("Active_Scenaro") = s
Calculate
Range("Scenario(i)").Value = Range("SensitivityResults").Value
Next s
Next i
Upvotes: 0
Views: 289
Reputation: 57743
You just need to append the counter i
as string to your fixed name Scenario
:
Range("Scenario" & i).Value = Range("SensitivityResults").Value
Upvotes: 3