NamedRange.Consolidate(Object, Object, Object, Object, Object) Method

Definition

Consolidates data from multiple ranges on multiple worksheets into the NamedRange control.

public object Consolidate (object Sources, object Function, object TopRow, object LeftColumn, object CreateLinks);
abstract member Consolidate : obj * obj * obj * obj * obj -> obj
Public Function Consolidate (Optional Sources As Object, Optional Function As Object, Optional TopRow As Object, Optional LeftColumn As Object, Optional CreateLinks As Object) As Object

Parameters

Sources
Object

The sources of the consolidation as an array of text reference strings in R1C1-style notation. The references must include the full path of sheets to be consolidated.

TopRow
Object

true to consolidate data based on column titles in the top row of the consolidation ranges; false to consolidate data by position. The default value is false.

LeftColumn
Object

true to consolidate data based on row titles in the left column of the consolidation ranges; false to consolidate data by position. The default value is false.

CreateLinks
Object

true to have the consolidation use worksheet links; false to have the consolidation copy the data. The default value is false.

Returns

Examples

The following code example sets the range of cells from B1 through D10 to random numbers and then uses the Consolidate method to consolidate this range into a NamedRange control.

This example is for a document-level customization.

private void SetConsolidation()
{
    Microsoft.Office.Tools.Excel.NamedRange namedRange1 =
        this.Controls.AddNamedRange(this.Range["A1"],
        "namedRange1");

    Excel.Range Range1 = this.Range["B1", "D10"];
    Range1.Formula = "=rand()";

    string[] source = new string[] { "Sheet1!R1C2:R10C4" };
    namedRange1.Consolidate(source, Excel.XlConsolidationFunction.xlSum,
        false, false, false);
}
Private Sub SetConsolidation()
    Dim namedRange1 As Microsoft.Office.Tools.Excel.NamedRange _
        = Me.Controls.AddNamedRange(Me.Range("A1"), _
        "namedRange1")

    Dim Range1 As Excel.Range = Me.Range("B1", "D10")
    Range1.Formula = "=rand()"

    Dim [source]() As String = {"Sheet1!R1C2:R10C4"}
    namedRange1.Consolidate([source], _
    Excel.XlConsolidationFunction.xlSum, False, False, False)

End Sub

Remarks

Optional Parameters

For information on optional parameters, see Optional Parameters in Office Solutions.

Applies to