Answer the question
In order to leave comments, you need to log in
How to automatically save cell value in Google Sheets daily?
There is a sum of changing values, every evening I need to store the value of this sum, so that they can then compare them with the next day, and so on. How can this be implemented?
Answer the question
In order to leave comments, you need to log in
The simplest thing is to create a script and connect a time trigger.
Add Code to Project to Table
/**
*
*/
function createTrigger() {
ScriptApp.getProjectTriggers().forEach(
(trigger) =>
trigger.getHandlerFunction() === 'saveData' &&
trigger.getEventType() === ScriptApp.EventType.CLOCK &&
(ScriptApp.deleteTrigger(trigger) ||
console.info(`Tirgger ${trigger.getUniqueId()} was deleted`))
);
// every minutes for testing
// ScriptApp.newTrigger('saveData').timeBased().everyMinutes(1).create();
// at 9 o'clock every days
ScriptApp.newTrigger('saveData').timeBased().atHour(9).everyDays(1).create();
}
/**
*
*/
function saveData() {
const book = SpreadsheetApp.openById(
'1FUSSiDQoXyvKXfzYydoUUfcCGYq_TskpRiwfb28_1Z0'
);
const sheet = book.getSheetByName('Лист1');
const value = sheet.getRange('A1').getValue();
book.getSheetByName('Лист2').appendRow([new Date(), value]);
console.info(`saveData was called successful`);
}
1FUSSiDQoXyvKXfzYydoUUfcCGYq_TskpRiwfb28_1Z0
to yours. Лист1!A1
and adds a new row to Лист2
. createTrigger
once from the editor. Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question