Skip to content Skip to sidebar Skip to footer

Typeerror: Cannot Call Method "getrange" Of Null. (line 9, File "code")

I am using the below filter function to copy data from one sheet to another, filtering out so that it only copies data if column AE = TRUE. When I use this script, it gives me the

Solution 1:

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.

Solution 2:

try changing as below

var sss = 
SpreadsheetApp.openById('1V3Tl4h43AC92K4gQtvdZ07k01QJOnfwSD1BKKTziHJU'); 
var ss = sss.getSheetByName('<20 Filter'); 
var sheet = ss.getSheets()[0];
varrange = sheet.getRange('A:AE'); 
var data = range.getValues();

note: getSheets Returns the sheet this range belongs to. please tick answered if this works for you.

Post a Comment for "Typeerror: Cannot Call Method "getrange" Of Null. (line 9, File "code")"