Big Green Alligator
Big Green Alligator

Reputation: 1185

How do I make Google Sheets refresh every 60 seconds?

I have an ImportJSON script in my Google Sheets retrieved from here. Now I have code:

=ImportJSON("http://date.jsontest.com/","/time", "")

which simply retrieves the time right now. My issue is that it does not refresh automatically.

How do I make it refresh every 60 seconds?

Upvotes: 2

Views: 3109

Answers (1)

Gordon Lenz
Gordon Lenz

Reputation: 21

I use a refresh script with the google apps script.

First you need to generate a random number to trick it into thinking its a new link.

  var min = Math.ceil(0);
  var max = Math.floor(99);
  var randomNum = Math.floor(Math.random() * (max - min + 1)) + min

After that you need to write to the cell you want to have the time

var ss = SpreadsheetApp.getActiveSpreadsheet();
var sh = ss.getSheetByName("Sheet1");

sh.getRange("A1").setFormula('=ImportJSON("http://date.jsontest.com/","/time", "","' + randomNum +'")';

Then you can set up the script to run whenever you want.

Upvotes: 2

Related Questions