I have the following Google Sheet with a tab called db:
In reality, the list is much longer. Eventually, I want to have a function triggered every hour to download data for 50 companies from Yahoo! Finance, as to not get rate restricted.
I am currently developing this function, and have the following in Code.gs:
function trigger() {
var db = SpreadsheetApp.getActiveSpreadsheet().getSheetByName('db');
var tickers = db.getRange('A2:A').getValues();
for (var row = 1; row <= 5; row++) {
console.log(tickers[row])
var data = yahoo(tickers[row]);
db.getRange(row, 2, 1, 3).setValues(data);
}
}
I have been messing around with different starting values for row, but just do not get the result as expected. Instead I get:
How can I:
- not overwrite the cells in
B1, C1, D1but have the data be inserted behind the respective tickers? - run the loop not 5 times (as is now hardcoded), but only as many times as there are tickers? I tried
row <= tickers.length()but got an error.

