Blackness
Blackness

Reputation: 71

Update google spreadsheet every n hours

I have google sheet that i want to use every day (like a main template), where I just need to add a few values in a specific cells,

i want to be able automatically or not to set those cell values everyday (let's say at midnight) back to my default values (let's say 0 or 1).

Any clue, any help, Thanks.

Upvotes: 2

Views: 3286

Answers (2)

Blackness
Blackness

Reputation: 71

So all I need to do was create a script for a sheet

function myFunction() {
    var ss = SpreadsheetApp.getActiveSpreadsheet();
    var sheet = ss.getSheetByName("Sheet1");
    var range = sheet.getRange("B2");
    var values = range.getValues();  
    if(values > 0) {
        range.setValue(0);
    } 
} 

And after that Click on Resources, Current project's triggers. Add new trigger and set it like this:

enter image description here

I think that's it, it is tested and work. If something is missing please edit my answer,deleting trigger or something like that.

Upvotes: 1

Jack Brown
Jack Brown

Reputation: 5892

You can use script triggers to run your script every nth hour.

Triggers: https://developers.google.com/apps-script/guides/triggers/installable

Check "Managing triggers manually" section.

You will have to create a script in google spreadsheet to change the values to a default value and setup up triggers to run that script every nth hour or so.

Upvotes: 1

Related Questions