Y
Y
Yana_do2021-06-10 13:52:00
Google Apps Script
Yana_do, 2021-06-10 13:52:00

How to set up data transfer from one table to another if the value in the cell has changed?

There is a Google table that displays at what stage of production the product is. Is it possible to transfer data from one sheet to another in certain cells if a specific stage is reached? In this case, the information should be deleted from the first sheet.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
G
Grigory Boev, 2021-06-14
@ProgrammerForever

Add an onEdit (e) function that will check if the data has changed and how. And if everything matches, then send the data to another table, and delete the original ones. At the same time, a simple trigger for access will no longer be enough and you need to make a full-fledged trigger for editing.
Here is the code snippet:

function onEdit(event) {
  const whiteList = ["Лист1", "Лист2"];
  let ss = event.source.getActiveSheet();                 //Текущий лист
  let address = event.range.getA1Notation().toUpperCase();//Адрес ячейки
  let row = event.range.getRow();                         //Номер строки
  let col = event.range.getColumn();                      //Номер столбца
  let newValue = event.value;								              //Новое значение
  let oldValue = event.oldValue;							            //Старое значение
  
  if (whiteList.indexOf(ss.getName())==-1) return;	//Указываем на каких листах должен работать скрипт
  
  //Что-то делаем...
};

D
Damir Makhmudov, 2021-07-12
@MakhmudovDamir

only with a script, share the table I will help [email protected]

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question