Robbit
Robbit

Reputation: 194

How to retrieve the very last row (empty or not) of a Google Sheet by script?

I want to prepare a Google Sheet for being printed partially. So I have to hide the unused rows at the bottom:

lastUsedSheetRow = ownSheet.getLastRow();
LastSheetRow = ownSheet.XXXXX()?;
ownSheet.hideRows(lastUsedSheetRow + 1 , LastSheetRow - lastUsedSheetRow + 1);

//hideRows(<index of first row to hide>, <number of rows to hide>);

What do I have to do to get the "veryLastSheetRow" of a sheet?

Upvotes: 1

Views: 282

Answers (2)

idfurw
idfurw

Reputation: 5852

getMaxRows()

Returns the current number of rows in the sheet, regardless of content.

Upvotes: 3

Mike Steelson
Mike Steelson

Reputation: 15318

Use this

ownSheet.getMaxRows()

Upvotes: 1

Related Questions