1

I'm trying to clear the contents of certain cells in the active sheet of my google sheets spreadsheet. Here's what I have so far:

function Reset() {
  var sheet = sheetName();
  var range = sheet.getRange("B4:G53");
  range.clearContent();
}

function sheetName(){ 
  return SpreadsheetApp.getActiveSpreadsheet().getActiveSheet().getName();
}

I get this error:

TypeError: Cannot find function getRange in object Copy of 5.7.18. (line 4, file "Code")

What am I doing wrong?

1 Answer 1

0

The problem is that your variable sheet doesn't make reference to a Class Sheet object.

Change

return SpreadsheetApp.getActiveSpreadsheet().getActiveSheet().getName();

by

return SpreadsheetApp.getActiveSpreadsheet().getActiveSheet();
0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.