Answer the question
In order to leave comments, you need to log in
How to clear cells of selected range (A2:B28) when cell B2 is activated in google sheets?
Guys, help me write a script so that when cell B2 is active, cells A2: B28 are cleared?
Answer the question
In order to leave comments, you need to log in
What does "active" mean? There is no "active cell" event, but there is a "cell changed" event - onEdit ( event )
Here is a code snippet for this function:
function onEdit(event) {
//Возникает при изменении ячейки
var ss = event.source.getActiveSheet();//Текущий лист
var address = event.range.getA1Notation().toUpperCase();//Адрес ячейки
var row = event.range.getRow(); //Номер строки
var col = event.range.getColumn(); //Номер столбца
var newValue = event.value; //Новое значение
var oldValue = event.oldValue; //Старое значение
if (["Лист1","Лист2"].indexOf(ss.getName())==-1) return; //Указываем на каких листах должен работать скрипт
//Что-то делаем...
};
if (address !="B2") return;
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question