3. OFFSET
OFFSET is widely used for both - accessing a specific value or a whole range. This function takes five parameters - origin, row_shift, col_shift, no. of rows, no. of columns. Let's understand this function with the following two examples.
Again lets take the same range, A1:E6. With the first three parameters, our target will be to reach our target value - 2.6. We can do that with:
Origin - A1, Row_shift = 3 (3 Down), Col_shift = 2 (2 Right)
Origin = C3, Row_shift = 0 (0 Down), Col_shift = 0 (0 Right)
Origin = E6, Row_shift = -2 (2 Up), Col_shift = -2 (2 Left)
Finally, no of rows and columns of required range = 1 row, 1 columns. Hence, to access 2.6, all three formulas will work.
= OFFSET(A1, 3, 2, 1, 1), or = OFFSET(A1:E5, 3, 2, 1, 1)
= OFFSET(C4, 0, 0, 1, 1) ,or = OFFSET(C4, , , 1, 1)
= OFFSET (E6, -2, -2, 1, 1)
The OFFSET function is used for range selection, which can be used in other functions where range data is required, such as INDEX or VLOOKUP. Just as in a single value, the first three parameters are used to reach the origin/first value of the target range. Then for the last two parameters, we require the dimension of the target array. For example, to access C4:D5 (Origin = C4, Size = 2 x 2),
= OFFSET (A1,3,2,2,2)
= OFFSET (C4,0,0,2,2)
= OFFSET (E6,-2,-2,2,2)
= OFFSET (D5,0,0,-2,-2)