Answer the question
In order to leave comments, you need to log in
How can I display cell changes in Google Sheets?
I have a cell, in it the data is updated by hands.
I need to create a record of the form on another sheet every time I change this cell.
дата - что изменилось
So far, the only option that comes to mind is to use google scripts, but I really would not want to.
Answer the question
In order to leave comments, you need to log in
While the option is only with scripts.
The add-on I am writing will be able to do this, but it is still being prepared for publication.
You need to track the onEdit (event) event and write a log to the desired sheet.
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; //Указываем на каких листах должен работать скрипт
//Можно при желании ещё фильтровать по строке/столбцу (row/col), или по старому/новому значению (oldValue/newValue)
var archive = SpreadsheetApp.getActiveSpreadsheet().getSheetByName("Архив");
archive.getRange(archive.getLastRow()+1, 1).setValue(
formatDateTime(new Date())+" " + "[" + ss.getName() + "!" + address + "] '" + (oldValue==undefined?"":oldValue) + "' >> '" + (newValue==undefined?"":newValue) +"'"
);
};
function formatDateTime(date) {
var dd = date.getDate();
if (dd < 10) dd = '0' + dd;
var mm = date.getMonth() + 1;
if (mm < 10) mm = '0' + mm;
var yy = date.getFullYear() % 100;
if (yy < 10) yy = '0' + yy;
var hh = date.getHours();
if (hh < 10) hh = '0' + hh;
var MM = date.getMinutes();
if (MM < 10) MM = '0' + MM;
var ss = date.getSeconds();
if (ss < 10) ss = '0' + ss;
return dd + '.' + mm + '.' + yy + ' ' + hh + ':'+ MM + ':'+ ss;
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question