VBA Excel – Cells, Ranges and Offset : Offset

Offset:

  • Offset property in VBA-Excel is used along with Range.
  • With the help of Offset property user can move around in the sheet.

Format:

Range(“StartingPoint”).Offset(NoOfRowsToBeMoved , NoOfColumnsToBeMoved)

Example :

Range(“A2”).Offset(1,0).Select

And compiler reads, move one cell down from A2 , which is A3.

Range(“A2”).Offset(-1,0).Select

And compiler reads, move one cell Up from A2 , which is A1.

Range(“A2”).Offset(1,1).Select

And compiler reads, move one cell down and one cell right from A2 , which is B3.

ActiveCell.Offset(1,1)

And compiler reads, move one cell down and one cell right from the selected cell.

 

2 thoughts on “VBA Excel – Cells, Ranges and Offset : Offset”

  1. In your post, you have:
    “Range(“A2”).Offset(-1,0).Select
    And com­piler reads, move one cell left from A2 , which is A1.”

    I believe this is incorrect. Offset(-1,0) should tell the compiler move one cell up, not left.

    Thanks for the post!

    Reply

Leave a Comment