var sheet = SpreadsheetApp.getActive().getSheetByName('Sheet1');
Error:
Cannot call method getSheetByName of Null
I need columns cleared of data. I would appreciate if someone could help me out with this.
var sheet = SpreadsheetApp.getActive().getSheetByName('Sheet1');
Error:
Cannot call method getSheetByName of Null
I need columns cleared of data. I would appreciate if someone could help me out with this.
Try this:
function resetColumns() {
var ss = SpreadsheetApp.getActiveSpreadsheet();
var sh = ss.getSheetByName('Tools')
sh.getRange("A1:A9").clearContent();
};
In order for the getSheetByName()
method to work, it must be chained to a spreadsheet object. If the object that the method is trying to work on has not been defined, then the method can not be found in the object. In Apps Script Object Oriented Programming, the method is inside of the object. The method can't be invoked as a stand alone function.