A
A
Andmakssc2020-09-07 15:22:26
Google Apps Script
Andmakssc, 2020-09-07 15:22:26

How to write a script in a Google spreadsheet for auto-completion and date reserve in several columns?

It turned out to register the script for only one column. It looks like this:

function onEdit(e) {
var sheet = e.source.getActiveSheet();
var idCol = e.range.getColumn();
var idRow = e.range.getRow();
if ( idCol == 2 && sheet.getName() =='Лист1' ) {
var Value = e.range.offset(1, +5).getValues(); 
if ( Value == "" ) {

var vartoday = getDate();



sheet.getRange(idRow, 6).setValue( vartoday );

}
}
}

// Returns YYYYMMDD-formatted date.
function getDate() {
var today = new Date();
today.setDate(today.getDate());
//return Utilities.formatDate(today, 'PST', 'yyyy.MM.dd');
return Utilities.formatDate(today, 'GMT+03:00', 'yyyy.MM.dd');
}


I need auto-completion of dates and a reserve in several different columns (I enter data on different days). That is, let's say, I enter in 1 column (cell) - the date appears in the 2nd column (cell). And I also enter it in the 3rd column (cell) - the date appears in the 4th column (cell). Etc. I will be grateful for help.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
N
Noir, 2020-09-07
@Andmakssc

add a loop for columns with step 2

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question