Bobby Thompson
Bobby Thompson

Reputation: 39

Update a cell every day at a specific time

To be frank I'm a complete newb at scripting and I have went as far as submitting a request to Googles support and was directed here.

What I'm needing is to be able to update a cell in a spreadsheet every day at a certain time, also I need to be able to do this multiple times daily.

Basically what I need is for is at 8:00 PM I need the values from B4 down to be copied into D4 down. When tried using the basic functions in Google the most that can be obtained is for the minute of 8:00 PM it will update then at 8:00 1 it goes back to 0. If I hadn't looked for days I wouldn't be asking for help. I apologize for my newbness.

A screenshot of the sheet I'm working with can be found via my Google Drive below.

https://drive.google.com/file/d/0B2GuBHPLz-Z_TWw2ZmtxNWJ0bkU/view?usp=sharing

Upvotes: 3

Views: 4711

Answers (1)

Amit Agarwal
Amit Agarwal

Reputation: 11268

You need to set up a time-based trigger that runs around 8 PM everyday and it should call the method that will update the cell.

function addTrigger() {
 ScriptApp.newTrigger("updateCell").timeBased().atHour(20).everyDays(1).create();
}

function updateCell() {
  var url = "<SPREADSHEET URL HERE>";
  var cell = "<CELL in A1 Notation>";
  SpreadsheetApp.openByUrl(url).getRange(cell).setValue(new Date());
}

You'll have to run the addTrigger method once for setting this up.

Upvotes: 3

Related Questions