S
S
Syrbatic2021-01-07 02:44:06
Google Apps Script
Syrbatic, 2021-01-07 02:44:06

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

1 answer(s)
A
Alexander Ivanov, 2021-01-07
@Syrbatic

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('Обновлено');
    }
  }
}

https://github.com/contributorpw/google-apps-script...
Example https://docs.google.com/spreadsheets/d/1LZi-bTd8-P...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question