title | keywords | f1_keywords | api_name | ms.assetid | ms.date | ms.localizationpriority | ||
---|---|---|---|---|---|---|---|---|
Range.Offset property (Excel) |
vbaxl10.chm144169 |
|
|
dfbbd1a2-2f73-fd6a-6277-4584823f55a4 |
05/11/2019 |
high |
Returns a Range object that represents a range that's offset from the specified range.
expression.Offset (RowOffset, ColumnOffset)
expression A variable that represents a Range object.
Name | Required/Optional | Data type | Description |
---|---|---|---|
RowOffset | Optional | Variant | 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 | Optional | Variant | 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. |
This example activates the cell three columns to the right of and three rows down from the active cell on Sheet1.
Worksheets("Sheet1").Activate
ActiveCell.Offset(rowOffset:=3, columnOffset:=3).Activate
This example assumes that Sheet1 contains a table that has a header row. The example selects the table, without selecting the header row. The active cell must be somewhere in the table before the example is run.
Set tbl = ActiveCell.CurrentRegion
tbl.Offset(1, 0).Resize(tbl.Rows.Count - 1, _
tbl.Columns.Count).Select
If RowOffset or ColumnOffset are 0 (zero) they can be omitted.
Select cell D1
Range("A1").Offset(, 3).Select
Select cell A5
Range("A1").Offset(4).Select
[!includeSupport and feedback]