C
C
Colt47pc2022-01-26 06:36:08
Google Apps Script
Colt47pc, 2022-01-26 06:36:08

Offset relative to the cell in which the script is written?

Is it possible to implement the following functionality through scripts: a function is inserted into a cell, in which, in turn, cells are indicated with an offset from the cell in which the function itself is inserted? This is necessary, because the function will be inserted into dynamic cells, while the data from the inserted function will always be statically located relative to the function. I have been searching for the 3rd day for information on Google in different languages, and it seems to me more and more that this is still impossible.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
G
Grigory Boev, 2022-01-26
@ProgrammerForever

You need Range.getCell()

let rightRange = SpreadsheetApp.getActiveRange().getCell(1, 2); // Соседний справа столбец
let bottomRange = SpreadsheetApp.getActiveRange().getCell(2, 1); // Строка ниже

If needed in a formula, use INDIRECT . Examples below:
In the same row, in the right column:
=INDIRECT("RC[1]";0)
In the same column, in the row above:
=INDIRECT("R[-1]C";0)
In column 4, in the same row:
=INDIRECT("RC4";0)
In column 4, in row 3:
=INDIRECT("R3C4";0)

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question