VBA Offset Range or Cell

Associated Files Download Links

The Offset Property is used to return a cell or a range, that is relative to a specified input cell or range.

Using Offset with the Range Object

You could use the following code with the Range object and the Offset property to select cell B2, if cell A1 is the input range:

The result is:

Using the Offset Property With the Range Object

Notice the syntax:

Range.Offset(RowOffset, ColumnOffset)

Positive integers tells Offset to move down and to the right. Negative integers move up and to the left.

 

 

The Offset property always starts counting from the top left cell of the input cell or range.

 

Using Offset with the Cells Object

You could use the following code with the Cells object and the Offset property to select cell C3 if cell D4 is the input range:

Cells(4, 4).Offset(-1, -1).Select

Selecting a Group of Cells

You can also select a group of cells using the Offset property. The following code will select the range which is 7 rows below and 3 columns to the right of input Range(“A1:A5”):

Range(“D8:D12”) is selected:

Using the Offset Property to Select a Group of Cells in VBA

You may also like some of this related content...

Ads