Expand Minimize

NamedRange.Offset Property

Gets a Microsoft.Office.Interop.Excel.Range that is offset from the NamedRange control.

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

NamedRange_OffsetType Offset { get; }

The Offset property is intended to be used with the following parameters.

Parameter

Description

RowOffset

The number of rows (positive, negative, or 0 (zero)) by which the range is to be offset. Positive values are offset downward, and negative values are offset upward. The default value is 0.

ColumnOffset

The number of columns (positive, negative, or 0 (zero)) by which the range is to be offset. Positive values are offset to the right, and negative values are offset to the left. The default value is 0.

If you attempt to use Offset without specifying any parameters, Offset will get a NamedRange_OffsetType object that is part of the Visual Studio infrastructure and is not intended to be used directly from your code.

Optional Parameters

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

The following code example creates a NamedRange and then adds text to a cell offset from the NamedRange by three columns and three cells.

This version is for a document-level customization.

Microsoft.Office.Tools.Excel.NamedRange offsetRange;
private void ActivateOffset()
{
    offsetRange = this.Controls.AddNamedRange(
         this.Range["B1"], "offsetRange");

    Excel.Range activateRange =
        (Excel.Range)this.offsetRange.Offset[3, 3];
    offsetRange.Value2 = "Original range.";
    activateRange.Value2 = "Offset range.";
    activateRange.Select();
}

This version is for an application-level add-in.

Was this page helpful?
(1500 characters remaining)
Thank you for your feedback
Show:
© 2014 Microsoft