4
4
4Chen2018-03-29 22:29:33
Google Sheets
4Chen, 2018-03-29 22:29:33

Script for recording changes in the values ​​of one cell for google spreadsheets?

We need a script for google spreadsheets that builds a graph of changes in the values ​​of one cell by day.
For excel, there is such a script - the script builds a column of changes with a given timeframe, and then a graph is built on it, but when transferring tables to google (because I am not familiar with them), it does not work.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
G
Grigory Boev, 2019-07-02
@ProgrammerForever

Use function onEdit(event) to determine if a cell has changed.
event.source..getActiveRange().getA1Notation() to determine the address of the cell
Then just accumulate the data somewhere. Below is the code to validate sheet "Sheet1" and cell "A1" in it. Data is accumulated on the "Archive" sheet

function onEdit(event){  
  if ((event.source.getActiveRange().getA1Notation()=="A1")&&(event.source.getActiveSheet().getName()=="Лист1")){
    var arc=SpreadsheetApp.getActiveSpreadsheet().getSheetByName("Архив");  
    arc.getRange(arc.getLastRow()+1,1,1,2).setValues();
  };
};

7
780048, 2020-05-15
@780048

Gregory, thanks for the script!
Indeed, it writes the values ​​when the cell changes, but is it possible to change the script so that it writes the value when not the cell changes, but the value in it?
Here's what I mean - the value in the cell whose history I want to keep is formed by a formula. It turns out that the value changes, but there is no cell change, so the data is not written to the history.
Maybe you can record once a day?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question