'Compare data (two cells) every week automatically in Google Sheet

I am using Google Sheet to manipulate data. I would like to automate one of my tasks. Every Monday I check if my data has increased or decreased, for that I use a file that updates my data every week in a different row. I would like to compare the last week with the one before. Basically, I would like to run a script that understands to compare one cell with the one right before so that I don't have to do it manually every week.

How can I do this with Google App Script ?

Thank you for your help!

Natacha



Solution 1:[1]

You can set up a Time-driven trigger to run once a week.

To compare one cell contents with another, you can use the getValue() method of the Range class:

const range1 = sheet.getRange("A1").getValue() // for example
const range2 = sheet.getRange("A2").getValue()

if (range1 < range2) {

}
else if (range1 > range2) {

}
// etc

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 I hope this is helpful to you