Answer the question
In order to leave comments, you need to log in
How to make the history of cell value changes into a special column?
There is a total amount
How
to
make it fit into the period called "history" for any change in this
amount in column A2
And so on
In other words, the history of the change in column A2
And also a question. How to make it so that when a number is entered in the column called Expenses, namely B2, the following action would take place
The amount written in cell B2 moves to the cell below and at the same time subtracts from the total amount and cell B2 is reset
And so on in a circle
Answer the question
In order to leave comments, you need to log in
If you right-click - there will be a history of changes. Or use onEdit () - this is less reliable, but works in simple situations.
//Telegram - @ProgrammerForever
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)
const archive = SpreadsheetApp.getActiveSpreadsheet().getSheetByName("Архив");
archive.getRange(archive.getLastRow()+1, 1).setValue(
formatDateTime(new Date())+" " + "[" + ss.getName() + "!" + address + "] '" + (oldValue==undefined?"":oldValue) + "' >> '" + (newValue==undefined?"":newValue) +"'"
);
};
function formatDate(date) {
try{
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;
return dd + '.' + mm + '.' + yy;
}catch(err){
return "";
};
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question