T
T
Toosik2019-11-22 17:43:56
Google
Toosik, 2019-11-22 17:43:56

Cell monitoring. How to make a script to monitor changes in a cell?

Good!
There is a need to create a script:
- assign a formula to cell A (group of cells, column) that will calculate the difference between the value just entered and the previous one in another cell B.
- force cell A to monitor the state of cell B with a certain time interval.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
Alexey Andreev, 2019-11-22
@LostAlly

App Script + time trigger, won't it hurt? Or I didn’t understand the task, or this is not a difficult question, but incorrectly formulated, you better visually guess what you need.

G
Grigory Boev, 2019-11-22
@ProgrammerForever

Look aside onEdit ( event ) - cell change event. Here is the code snippet:

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;	//Указываем на каких листах должен работать скрипт
  
  //Что-то делаем...
  };

The time interval can be set in the project triggers by attaching a time trigger to any function.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question