編輯

共用方式為


Scenarios.Add(String, Object, Object, Object, Object, Object) Method

Definition

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

public Microsoft.Office.Interop.Excel.Scenario Add (string Name, object ChangingCells, object Values, object Comment, object Locked, object Hidden);
Public Function Add (Name As String, ChangingCells As Object, Optional Values As Object, Optional Comment As Object, Optional Locked As Object, Optional Hidden As Object) As Scenario

Parameters

Name
String

Required String. The scenario name.

ChangingCells
Object

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

Values
Object

Optional Object. 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 in ChangingCells.

Comment
Object

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

Locked
Object

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

Hidden
Object

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

Returns

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.

Applies to