Log cell value on specific time intervals

Viewed 91

The function =GOOGLEFINANCE("NASDAQ:GOOG","PRICE") fetches the realtime price in Google Sheets. So if it is required to log the value of the above function every 15 minutes and reset the log at midnight, is there any way to do so? Mainly I have to log value of a derived field which uses value of this function.

Required format

| TIME (in 24h format) | Price |

1 Answers

Here is a solution. Put a trigger (15mn) on 'periodic'

function activate(x) {
  return x
}
function periodic(){
  var sh=SpreadsheetApp.getActiveSpreadsheet().getActiveSheet()
  var der=sh.getLastRow()+1
  sh.getRange('A'+der).setValue(new Date())
  sh.getRange('B'+der).setValue(sh.getRange('A2').getValue())
  sh.getRange('B1').setValue(!sh.getRange('B1').getValue())
}

https://docs.google.com/spreadsheets/d/1QM7uI1xsJaCDkyEZ1UvE3knc00gFlgt_BItJQRb9M70/copy

Related