This documentation is archived and is not being maintained.

NamedRange.Insert Method

Inserts a cell or a range of cells into the NamedRange control and shifts other cells away to make space.

Namespace: Microsoft.Office.Tools.Excel
Assembly: Microsoft.Office.Tools.Excel (in

public Object Insert (
	[OptionalAttribute] Object Shift,
	[OptionalAttribute] Object CopyOrigin



Specifies which way to shift the cells. Can be one of the following XlInsertShiftDirection values: xlShiftToRight or xlShiftDown. If this argument is omitted, Microsoft Office Excel decides based on the shape of the range.


One of the XlInsertFormatOrigin values that specifies where to obtain the format to apply to the new cells.

Optional Parameters

For information on optional parameters, see Understanding Optional Parameters in COM Interop.

The following code example sets values in cells A1 through A3, and then uses the Insert method to insert a blank cell into a NamedRange control named NamedRange1 that is set to cell A1. This operation shifts the cells in the range down, which means that NamedRange1 is now set to cell A2. To demonstrate this, the example sets the value of NamedRange1 to Raven, which displays in cell A2.

private void InsertIntoRange()
    this.Range["A1", missing].Value2 = "Robin";
    this.Range["A2", missing].Value2 = "Sparrow";
    this.Range["A3", missing].Value2 = "Crow";

    Microsoft.Office.Tools.Excel.NamedRange namedRange1 =
        this.Controls.AddNamedRange(this.Range["A1", missing],

    namedRange1.Insert(Excel.XlInsertShiftDirection.xlShiftDown, missing);
    namedRange1.Value2 = "Raven";