Есть ли функция для выбора новой ячейки в Google Таблицах с помощью Google-Apps-Script?

#google-apps-script

#google-apps-script

Вопрос:

Мне нужно, чтобы Google sheets выбирал определенную ячейку (B3) при вызове функции (makeActive). Ячейка должна быть выбрана так, как если бы пользователь сам нажал на ячейку.

Ответ №1:

Это так просто, как говорится в документах:

 // The code below sets the cell B5 in the first sheet as the current cell.
var cell = SpreadsheetApp.getActiveSpreadsheet().getSheets()[0].getRange('B5');
SpreadsheetApp.setCurrentCell(cell);

var selection = SpreadsheetApp.getSelection();
// Current cell: B5
var currentCell = selection.getCurrentCell();