var range = sheet.getRange(i, 1);

It only lets me use

var range = sheet.getRange('A1');

otherwise it gives me error message

Exception: The parameters (String,number) don't match the method signature for SpreadsheetApp.Spreadsheet.getRange. addStats


1 Answer 1


The error message tells that the variable sheet does not refer to a sheet (tab) in the spreadsheet but to the whole spreadsheet.

The .getRange('A1') method exists with both sheet and spreadsheet objects. With a spreadsheet object, the method gets a range in the sheet that shows as the first one in the tab bar of the spreadsheet. The .getRange(1, 1) method, however, is only available with sheet objects.

To get a sheet object, use SpreadsheetApp.getActiveSheet() or similar methods, like this:

 const sheet = SpreadsheetApp.getActiveSheet();

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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