Reputation: 1
Why AppScript in google sheets doesn't find the range in the sheet?The SpreadsheetApp finds the sheet but shows error in line 6.
I tried ActiveRange and just getRange defining this in the sheet, but I always see this error.
Please help me I'm not a programmer.
Below is my function:
function sendEmailtoworkers() {
let ss = SpreadsheetApp.getActiveSpreadsheet();
let sheet = ss.getSheetByName('number')[0];
let list = sheet.getRange(2,2,9,2);
MailApp.sendEmail( list, "пупкин", "Пожалуйста, зайди на этот файл: docs.google.com/spreadsheets/d/…);
}
Upvotes: 0
Views: 7500
Reputation: 11
getSheetByName('number')
will give you the sheet object, you're trying to access [0]
from that, which returns undefined
.
You can either use
let sheet = ss.getSheetByName('number')
or
let sheet = ss.getSheets()[0];
getSheets()
returns list of sheet objects, you can access through index.
To know more, click here!
Upvotes: 1