Scenarios.Add Method
Creates a new scenario and adds it to the list of scenarios that are available for the current worksheet.
Namespace: Microsoft.Office.Interop.Excel
Assembly: Microsoft.Office.Interop.Excel (in Microsoft.Office.Interop.Excel.dll)
Syntax
'Declaration
Function Add ( _
Name As String, _
ChangingCells As Object, _
Values As Object, _
Comment As Object, _
Locked As Object, _
Hidden As Object _
) As Scenario
'Usage
Dim instance As Scenarios
Dim Name As String
Dim ChangingCells As Object
Dim Values As Object
Dim Comment As Object
Dim Locked As Object
Dim Hidden As Object
Dim returnValue As Scenario
returnValue = instance.Add(Name, ChangingCells, _
Values, Comment, Locked, Hidden)
Scenario Add(
string Name,
Object ChangingCells,
Object Values,
Object Comment,
Object Locked,
Object Hidden
)
Parameters
Name
Type: System.StringRequired String. The scenario name.
ChangingCells
Type: System.ObjectRequired Object. A Range object that refers to the changing cells for the scenario.
Values
Type: System.ObjectOptional 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
Type: System.ObjectOptional 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
Type: System.ObjectOptional Object. True to lock the scenario to prevent changes. The default value is True.
Hidden
Type: System.ObjectOptional Object. True to hide the scenario. The default value is False.
Return Value
Type: Microsoft.Office.Interop.Excel.Scenario
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.