Answer the question
In order to leave comments, you need to log in
Setting date to adjacent column by checkbox true?
Friends, we need your help!
There is an infinitely filled table starting from line 10.
In the 6th column of each line, there is a checkbox
. By clicking on the checkbox (in the position true) in the 7th column of the same line, substitute the current date.
I searched everything, broke my whole head - I don’t understand how to do it
.
Answer the question
In order to leave comments, you need to log in
Add a script to your table
/**
*
*/
function onEdit(e) {
const sheetName = 'Sheet6'; // Имя листа, который отслеживается
const colToStamp = 7; // Номер колонки для даты
if (e && e.range && e.range.getRow() > 9 && e.range.getColumn() == 6) {
const sheet = e.range.getSheet();
if (sheet.getName() == sheetName) {
const writeVal =
e.value == true || e.value == 'TRUE' || e.value == 'ИСТИНА'
? new Date()
: '';
sheet.getRange(e.range.rowStart, colToStamp).setValue(writeVal);
SpreadsheetApp.getActive().toast('Обновлено');
}
}
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question