I have two worksheet/sheet in a google sheet, namely "Company" and "Data". In the "Data" sheet I have a button "Hide Rows" which will hide certain rows on "Company" Sheet on click. For this I have written following AppScript.

function hideRows() {
  const ss =  SpreadsheetApp.getActive().getSheetByName('Company');

But it is showing following error upon clicking the "Hide Rows" button:

Exception: The parameters (number) don't match the method signature for SpreadsheetApp.Sheet.hideRow.

How to correct the code so that I can hide one or several rows of separate sheet?

1 Answer 1


Change your code to ss.hideRows(3)


There are several ways to hide rows in a sheet, but each has a specific syntax.

hideRow(row) - Doc ref

This is the method that you called but this hides a row in a given range. So if you wanted to use that method, you should have specified a range. For example:

var range = sheet.getRange("A3")

hideRows(rowIndex) - Doc Ref

This alternative hides the row at the given index. This is the method that you were trying to use and the code would be:


hideRows(rowIndex, numRows) - Doc ref

There's also amethod if you want to hide multiple (contiguous) rows through a single command.

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.