Add Method (Scenarios Collection)

See Also         Example         Applies To

Creates a new scenario and adds it to the list of scenarios that are available for the current worksheet. Returns a Scenario object.

Syntax

expression.Add(Name, ChangingCells, Values, Comment, Locked, Hidden)

expression   Required. An expression that returns a Scenarios object.

Name   Required String. The scenario name.

ChangingCells   Required Variant. A Range object that refers to the changing cells for the scenario.

Values   Optional Variant. An array that contains the scenario values for the cells in ChangingCells. If this argument is omitted, the scenario values are assumed to be the current values in the cells inChangingCells.

Comment   Optional Variant. A string that specifies comment text for the scenario. When a new scenario is added, the author name and date are automatically added at the beginning of the comment text.

Locked   Optional Variant. True to lock the scenario to prevent changes. The default value is True.

Hidden   Optional Variant. True to hide the scenario. The default value is False.

Remarks

A scenario name must be unique; Microsoft Excel generates an error if you try to create a scenario with a name that’s already in use.