Search notes:

Excel function: offset

The worksheet function offset() returns a reference to a range that is offset from a specific address by a given amount of rows and columns.
offset(reference, rows, cols, [height], [width])

Simple example

In the following simple example, =offset(b2, 3, 2) returns 4 - 3 because this is the value that is found by going from b2 three rows down and 2 columns to the right.
Similarly, the next offset function returns 5 - 4 because the offset is now started one row and one cell down and right, respectively.
option explicit

sub main() ' {

    testdata

    cells(2, 8).formula = "=offset(b2, 3, 2)
    cells(3, 8).formula = "=offset(c3, 3, 2)

end sub ' }

sub testdata() ' {

  '
  ' Clear testdata from previous run
  '
    activeSheet.cells.clearContents

  '
  ' Fill two dimensional array
  '
    dim x, y as long
    for x = 1 to 5: for y = 1 to 5
        cells(y + 1, x + 1).numberFormat = "@"
        cells(y + 1, x + 1) = y & " - " & x
    next y: next x

end sub ' }
Github repository about-Excel, path: /functions/offset/simple.bas

See also

The implicit intersection operator @
indirect() is another function that returns a reference.
offset is a volatile function.
Excel functions
The offset method of the range object of the Excel Object Model.

Index