Please bear with me, I'm a noob at JavaScript. I'm getting "Range not found" (line 5) when trying to run this code in a Google Spreadsheet:
function saveData() {
var ss = SpreadsheetApp.getActiveSpreadsheet();
var sheet = ss.getSheets()[0];
var url = sheet.getRange('Sheet1!A1').getValue();
var follower_count = sheet.getRange('Sheet1!B1').getValue();
var date = sheet.getRange('Sheet1!C1').getValue();
sheet.appendRow([url,follower_count,date]);
}
My sheet contains values in all the those cells (A1,B1,C1)
. What am I missing?
Thanks!
if your sheet's name is Sheet1 then try this piece:
function saveData() {
var ss = SpreadsheetApp.getActive();
var sheet = ss.getSheetByName('Sheet1');
var url = sheet.getRange('A1').getDisplayValue();
var follower_count = sheet.getRange('B1').getDisplayValue();
var date = sheet.getRange('C1').getDisplayValue();
sheet.appendRow([url,follower_count,date]);
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.