TypeError: Cannot call method “getRange” of null. (line 9, file “Code”)

It means that tss.getSheetByName('Zones >20 Riders'); did not return anything. You need to check that indeed a sheet was found before trying to access it.

Here’s the example provided at Google Docs:

var sheet = SpreadsheetApp.getActiveSpreadsheet().getSheetByName("Expenses");

if (sheet != null) {
    // Do your thing
}

If you are not sure what a method does, always check the documentation. For example, getRange returns the specified Range of cells in the sheet.

Leave a Comment