Add Method

Add method as it applies to the ChAxes object.

Adds an axis to a chart. Creates a new ChAxis object.

expression**.Add(Scaling)**

*expression   * Required. An expression that returns a ChAxes object.

Scaling   Required ChScaling object. A scaling object from another axis or series.

Add method as it applies to the ChCharts object.

Creates a new, empty chart. Returns a ChChart object.

expression**.Add(Index)**

*expression   * Required. An expression that returns a ChCharts object.

Index   Optional Long. Specifies the position of the new chart. Specifying zero (0) inserts the chart at the beginning of the collection. The default value is -1, which means that if you do not specify this argument, the new chart is inserted at the end of the collection.

Add method as it applies to the ChDataLabelsCollection object.

Adds data labels to the specified series. Creates a new, uninitialized ChDataLabels object and adds it to the specified ChDataLabelsCollection collection. A series can have only one set of data labels; this method fails if the ChDataLabelsCollection collection already contains a ChDataLabels object.

expression**.Add()**

*expression   * Required. An expression that returns a ChDataLabelsCollection object.

Add method as it applies to the ChErrorBarsCollection object.

Adds error bars to a series. Creates a new, uninitialized ChErrorBars object and adds it to the specified ChErrorBarsCollection collection. A chart can contain only one set of error bars; this means that an XY (Scatter) chart can contain either x or y error bars, but not both.

expression**.Add()**

*expression   * Required. An expression that returns a ChErrorBarsCollection object.

Add method as it applies to the ChSegments object.

Adds a segment to a format map. Returns a ChSegment object.

expression**.Add()**

*expression   * Required. An expression that returns a ChSegments object.

Add method as it applies to the ChSeriesCollection object.

Adds a series to a chart. Creates a new, empty ChSeries object at the specified position in the ChSeriesCollection collection.

expression**.Add(Index)**

*expression   * Required. An expression that returns a ChSeriesCollection object.

Index   Optional Long. Specifies the position of the new series in the collection. Specifying zero (0) places the new series at the beginning of the collection. The default value is -1, which means if you do not specify this argument, the new series is placed at the end of the collection.

Add method as it applies to the ChTrendlines object.

Adds a trendline to a series. Creates a new, uninitialized ChTrendline object and adds it to the end of the specified ChTrendlines collection.

expression**.Add()**

*expression   * Required. An expression that returns a ChTrendlines object.

Add method as it applies to the ElementExtensions object.

Creates a new ElementExtension object.

expression**.Add(ElementID**, FailIfThere)

*expression   * Required. An expression that returns an ElementExtensions object.

ElementID   Required String. Specifies the ID tag of an HTML element that will be extended by the new ElementExtension object.

FailIfThere   Optional Boolean. If this argument is set to True and the object specified by ElementID already has an element extension, the Add method fails. If this argument is set to False (or not specified), the existing element extension is replaced.

Add method as it applies to the GroupingDefs object.

Creates a new grouping definition. Returns a GroupingDef object.

expression**.Add(GroupingDefName**, GroupingFieldName, PageFieldName, Index)

*expression   * Required. An expression that returns a GroupingDefs object.

GroupingDefName   Required String. Specifies the name of the new grouping definition.

GroupingFieldName   Required String. Specifies the name of the grouping field used to create the new definition.

PageFieldName   Required String. Specifies the name of the page field used to create the new definition.

Index   Optional Variant. Specifies the ordinal position, the name, or the actual object reference for the grouping definition before which the new grouping definition will be added. If you do not specify this argument, the new grouping definition is added at the end of the collection.

Remarks

A recordset definition that represents a grouping level has an object type of GroupingDef, which is derived from the RecordsetDef object representing the recordset definition. As far as control binding is concerned, a recordset defined by a GroupingDef object behaves just like a recordset defined by a RecordsetDef object.

Add method as it applies to the GroupLevels object.

Creates a new group level. Returns a GroupLevel object.

expression**.Add(RecordSource**, FailIfThere)

*expression   * Required. An expression that returns a GroupLevels object.

RecordSource   Required String. Specifies the name of the record source for the new group level.

FailIfThere   Optional Boolean. If this argument is set to True and the new group level already exists, the Add method fails. The default value is False.

Add method as it applies to the Sheets and Worksheets objects.

Creates a new worksheet. The new worksheet becomes the active sheet.

expression**.Add(Before**, After, Count, Type)

*expression   * Required. An expression that returns one of the above objects.

Before   Optional Variant. An object that specifies the sheet before which the new sheet is added.

After   Optional Variant. Optional Variant. An object that specifies the sheet after which the new sheet is added.

Count   Optional Variant. The number of sheets to be added. The default value is one.

Type   Optional Variant. Specifies the sheet type. Can be one of the following XlSheetType constants: xlWorksheet.

Remarks

If Before and After are both omitted, the new sheet is inserted before the active sheet.

Add method as it applies to the PageFields object.

Creates a new page field. Returns a PageField object.

expression**.Add(Source**, FieldType, Name, TotalType, Index)

*expression   * Required. An expression that returns one a PageFields object.

Source   Required Variant. Specifies the source for the new page field. For new fields of type dscOutput, this argument specifies a SchemaField object or the name of a schema field. For fields of type dscCalculated, this argument specifies the expression for the calculated field. For new fields of type dscGrouping, this argument specifies a PageField object or the name of a page field on which this grouping is based

FieldType   Optional Variant. Specifies the new field type. The default value and allowed values depend on the parent object used with this method. For more information, see the "Remarks" section in this topic.

Name   Optional Variant. Specifies the name of the new page field. If you do not specify this argument, the name of an output field is the same as the schema field it is based on, the name of a grouping field is "By<pagefieldname>" or "<agg function>of<pagefieldname>", and the name of a calculated field is "Expr". In all cases, numerals are automatically appended to the new name to make it unique, if necessary.

DscTotalTypeEnum

DscTotalTypeEnum can be one of these DscTotalTypeEnum constants.
dscAny
dscAvg
dscCount
dscMax
dscMin
dscNonedefault
dscStdev
dscSum

Index   Optional Variant. Specifies the ordinal position, the name, or the actual object reference for the page field before which the new page field is added. If you do not specify this argument, the new page field is added at the end of the collection. Use this argument only with a GroupingDef object's PageFields collection. For more information, see the "Remarks" section following this paragraph.

Remarks

The PageFields collection has three different parent objects: RecordsetDef, PageRowsource, and GroupingDef. You use the same Add method for all of these parent objects. There are, however, some differences in defaults and allowed values depending on which parent object you use.

  • For RecordsetDef.PageFields.Add, the default value for FieldType is dscOutput. Other allowed FieldType values are dscCalculated and dscGrouping. When FieldType is dscOutput, the specified source field will be added to the primary page row source in the recordset definition; thus, the source field must exist in the corresponding schema row source. When FieldType is dscGrouping, the TotalType value must be something other than dscNone (a nonaggregate grouping field can exist only in a grouping definition, not in a recordset definition). You cannot use the Index argument in this scenario.
  • For PageRowsource.PageFields.Add, the default and only allowed value for FieldType is dscOutput. The only allowed value for TotalType is dscNone. You cannot use the Index argument in this scenario. Using the Add method, you can add output fields to look up row sources.
  • For GroupingDef.PageFields.Add, the default value for FieldType is dscGrouping. The other allowed FieldType value is dscCalculated. You can use the Index argument in this scenario (sequence is important in groupings of definitions).

Add method as it applies to the LookupRelationships and SublistRelationships objects.

Creates a new lookup join relationship or a new sublist relationship. Returns a PageRelationship object.

expression**.Add(PageRowsource**, SchemaRelationship)

*expression   * Required. An expression that returns one of the above objects.

PageRowsource   Required PageRowsource object. Specifies the page row source on the "one" side of the one-to-many page relationship.

SchemaRelationship   Required SchemaRelationship object. Describes the connecting fields between the parent page row source on the "many" side of the one-to-many relationship and the page row source specified in this method.

Remarks

The SublistRelationships collection contains PageRelationship objects of type dscSublist for which a RecordsetDef object is the "one" side (the parent) of a one-to-many relationship.

Add method as it applies to the ParameterValues object.

Creates a new parameter value. Returns a ParameterValue object.

expression**.Add(ParameterName**, Value)

*expression   * Required. An expression that returns a ParameterValues object.

ParameterName   Required String. Specifies the parameter name.

Value   Optional Variant. Specifies the value of the parameter.

Add method as it applies to the RecordsetDefs object.

Creates a new recordset definition. Returns a RecordsetDef object.

expression**.Add(SchemaRowsource**, Name)

*expression   * Required. An expression that returns a RecordsetDefs object.

SchemaRowsource   Required Variant. Specifies the schema row source that will be used to create the new recordset definition. This argument can be a SchemaRowsource object or the name of an existing schema row source.

Name   Optional Variant. Specifies the name of the new recordset definition. If you do not specify this argument, the new recordset definition has the same name as the schema row source specified by the SchemaRowsource argument; if necessary, numerals are automatically appended to the new name to make it unique.

Remarks

Using a single AddNew method call, you can create a recordset definition, page row source, and schema row source.

Add method as it applies to the SchemaFields object.

Creates a new schema field. Returns a SchemaField object.

expression**.Add(Name**, DataType, Length)

*expression   * Required. An expression that returns a SchemaFields object.

Name   Required String. Specifies the name of the new schema field.

DataType   Required ADO DataTypeEnum. Specifies the data type of the new schema field.

Length   Optional Variant. Specifies the length of the new schema field.

Remarks

In design mode in Microsoft Access, the SchemaFields collection is automatically filled with the available schema fields.

Add method as it applies to the SchemaParameters object.

Creates a new schema parameter. Returns a SchemaParameter object.

expression**.Add(Name**, DataType, Size, Scale, Precision, Direction)

*expression   * Required. An expression that returns a SchemaParameters object.

Name Required String. Specifies the name of the new schema parameter.

DataType   Optional Variant. Specifies the data type of the new schema parameter. Can be one of the ADO DataTypeEnum constants.

Size   Optional Variant. Specifies the maximum length of the new schema parameter.

Scale   Optional Variant. Specifies the maximum number of digits to the right of the decimal point.

Precision   Optional Variant. Specifies the maximum number of digits used for the parameter.

Direction   Optional Variant. Specifies whether the parameter is an input parameter, an output parameter, both an input and output parameter, or a procedure return value. As only input parameters are supported, you should not specify this argument.

Remarks

In design mode in Microsoft Access, the SchemaParameters collection is automatically filled with the available schema parameters.

Add method as it applies to the SchemaRelatedFields object.

Creates a new related field. Returns a SchemaRelatedField object.

expression**.Add(ManySchemaField**, OneSchemaField)

*expression   * Required. An expression that returns a SchemaRelatedFields object.

ManySchemaField    Required String. Specifies the name of the schema field on the "one" side of the one-to-many relationship.

OneSchemaField    Required String. Specifies the name of the schema field on the "many" side of the one-to-many relationship.

Remarks

A SchemaRelatedField object describes the column pairings that make up a SchemaRelationship object. The names of these fields are used in generating join clauses in SQL and parent-child relationships in a hierarchy.

In design mode in Microsoft Access, the SchemaFields collection is automatically filled with the available schema fields.

Add method as it applies to the SchemaRelationships object.

Creates a new schema relationship. Returns a SchemaRelationship object.

expression**.Add(Name**, ManySchemaRowsource, OneSchemaRowsource, ManySchemaField, OneSchemaField)

*expression   * Required. An expression that returns a SchemaRelationships object.

Name    Required String. Specifies the name of the new schema relationship.

ManySchemaRowsource    Required String. Specifies the name of the row source on the "many" side of this one-to-many relationship.

OneSchemaRowsource    Required String. Specifies the name of the row source on the "one" side of this one-to-many relationship.

ManySchemaField    Required String. Specifies the name of the schema field on the "many" side of this one-to-many relationship.

OneSchemaField    Required String. Specifies the name of the schema field on the "one" side of this one-to-many relationship.

Remarks

In design mode in Microsoft Access, the SchemaRelationships collection is automatically filled with the available schema relationships.

Add method as it applies to the SchemaRowsources object.

Creates a new schema row source. Returns a SchemaRowSource object.

expression**.Add(Name**, RowsourceType, CommandText)

*expression   * Required. An expression that returns a SchemaRowsources object.

Name   Required String. Specifies the name of the new row source.

DscRowsourceTypeEnum

DscRowsourceTypeEnum can be one of these DscRowsourceTypeEnum constants.
dscCommandFile
dscCommandText
dscProcedure
dscTable
dscView

CommandText   Optional Variant. The schema row source command text. For more information, see the Help topic for the CommandText property.

Remarks

In design mode in Microsoft Access, the SchemaRowsources collection is automatically filled with the available schema row sources.

Add method as it applies to the Criteria object.

Adds an AutoFilter criterion.

expression**.Add(Criterion)**

*expression   * Required. An expression that returns a Criteria object.

Criterion   Required String. Specifies the new criterion.

Add method as it applies to the Names object.

Defines a new name. Returns a Name object.

expressionAdd(Name, RefersTo, Visible, MacroType, ShortcutKey, Category, NameLocal, RefersToLocal, CategoryLocal, RefersToR1C1, RefersToR1C1Local)

*expression   * Required. An expression that returns a Names object.

Name   Optional Variant. Required if NameLocal isn't specified. The text to use as the name (in the language of the macro). Names cannot include spaces and cannot look like cell references.

RefersTo   Optional Variant. Required unless one of the other RefersTo arguments is specified. Describes what the name refers to (in the language of the macro, using A1-style notation).

Visible   Optional Variant. This argument is not supported.

MacroType   Optional Variant. This argument is not supported.

ShortcutKey   Optional Variant. This argument is not supported.

Category   Optional Variant. This argument is not supported.

NameLocal   Optional Variant. Required if Name isn't specified. The text to use as the name (in the language of the user). Names cannot include spaces and cannot look like cell references.

RefersToLocal   Optional Variant. Required unless one of the other RefersTo arguments is specified. Describes what the name refers to (in the language of the user, using A1-style notation).

CategoryLocal   Optional Variant. This argument is not supported.

RefersToR1C1   Optional Variant. Required unless one of the other RefersTo arguments is specified. Describes what the name refers to (in the language of the macro, using R1C1-style notation).

RefersToR1C1Local   Optional Variant. Required unless one of the other RefersTo arguments is specified. Describes what the name refers to (in the language of the user, using R1C1-style notation).

Add method as it applies to the ListRows collection.

Adds a new row to the ListRows collection of the current XML list by promoting the cells in the insert row to an added row. Returns a ListRow object that contains the values of the newly created row.

expression**.Add()**

*expression   * Required. An expression that returns a **ListRows**collection.

Add method as it applies to the XmlDataBindings collection.

Adds a new data binding to the XmlDataBindings collection of the current Workbook.

expression**.Add(bstrBindingData)**

*expression   * Required. An expression that returns an XmlDataBindings collection.

bstrBindingData    Required. String. An XML fragment that defines the configuration data for the new data binding. You can return configuration data for an existing binding using the BindingData property. For information on the XML schema of a data binding for the Spreadsheet component, search the Microsoft Developer Network (MSDN) Web site.

Remarks

A data binding defined by an XmlDataBinding object can query or update data from a data retrieval service, SOAP Web Service, XML file, or another Spreadsheet component.

Calling the Add method to add a binding without first adding the associated map will generate a run-time error. To avoid this error, you must first call the Add method on the XmlMaps collection to add an associated map.

Add method as it applies to the XmlMaps collection.

Adds a new XML map to the XmlMaps collection of the current Workbook.

expression**.Add(bstrMapData)**

*expression   * Required. An expression that returns an XmlMaps collection.

bstrMapData    Required. String. An XML fragment that defines the configuration data for the new XML map. You can return configuration data for an existing XML map using the MapData property. For information on the XML schema of an XML map for the Spreadsheet component, search the Microsoft Developer Network (MSDN) Web site.

Example

As it applies to the ChCharts object.

This example adds a chart to the chart workspace.

Set cht = ChartSpace1.Charts.Add

As it applies to the ChDataLabelsCollection object.

This example adds data labels to the specified series in the chart workspace.

Set ch = ChartSpace1.Charts(0)
ch.SeriesCollection(0).DataLabelsCollection.Add

As it applies to the ChErrorBarsCollection object.

This example adds error bars to the specified series in the chart workspace.

Set eb = ChartSpace1.Charts(0).SeriesCollection(0).ErrorBarsCollection.Add

As it applies to the ChSeriesCollection object.

This example adds a new series to the specified chart in the chart workspace and then sets the values for the new series.

Dim values(7)

values(0) = 0
values(1) = 1
values(2) = 10
values(3) = 25
values(4) = 30
values(5) = 40
values(6) = 60

Set s2 = ChartSpace1.Charts(0).SeriesCollection.Add
Set c = ChartSpace1.Constants
s2.SetData c.chDimValues, c.chDataLiteral, values

As it applies to the ChTrendlines object.

This example adds a trendline to the specified series in the chart workspace.

Set trndline = ChartSpace1.Charts(0).SeriesCollection(0).Trendlines.Add

As it applies to the Criteria object.

This example turns on the AutoFilter for the range A1:J22, and then it sets filters for columns 1 and 3 and applies the filters.

Spreadsheet1.Range("a1:j22").AutoFilter
Set af = Spreadsheet1.ActiveSheet.AutoFilter
Set filterColumnOne = af.Filters(1)
Set filterColumnThree = af.Filters(3)
filterColumnOne.Criteria.Add "blue" ' Don't show blue in column 1.
filterColumnOne.Criteria.Add "green" ' Don't show green in column 1.
filterColumnThree.Criteria.Add "yellow" ' Don't show yellow in column 3.
af.Apply

Applies to | ChAxes Collection | ChCharts Collection | ChDataLabelsCollection Collection | ChErrorBarsCollection Object | ChSegments Object | ChSeriesCollection Collection Object | ChTrendlines Collection | Criteria Object | ElementExtensions Collection Object | GroupingDefs Collection Object | GroupLevels Collection Object | ListRows Collection | LookupRelationships Collection Object | Names Collection | PageFields Collection Object | ParameterValues Collection Object | RecordsetDefs Collection Object | SchemaFields Collection Object | SchemaParameters Collection Object | SchemaRelatedFields Collection Object | SchemaRelationships Collection Object | SchemaRowsources Collection Object | Sheets Collection | SublistRelationships Collection Object | Worksheets Collection Object | XmlDataBindings Collection | XmlMaps Collection

See Also | AddNew Method | Delete Method