Remarks

A scenario is a group of input values (called changing cells) that's named and saved.

Example

Use the method to return the Scenarios collection. The following example creates a summary for the scenarios on the worksheet named "Options," using cells J10 and J20 as the result cells.

Visual Basic for Applications
Worksheets("options").Scenarios.CreateSummary _ resultCells:=Worksheets("options").Range("j10,j20")

Use the method to create a new scenario and add it to the collection. The following example adds a new scenario named "Typical" to the worksheet named "Options." The new scenario has two changing cells, A2 and A12, with the respective values 55 and 60.

Visual Basic for Applications
Worksheets("options").Scenarios.Add name:="Typical", _ changingCells:=Worksheets("options").Range("A2,A12"), _ values:=Array("55", "60")

Use Scenarios(), where is the scenario name or index number, to return a single Scenarioobject. The following example shows the scenario named "Typical" on the worksheet named "Options."

Visual Basic for Applications
Worksheets("options").Scenarios("typical").Show
Scenarios Collection Scenarios Collection Object

See also:

index index