HOlson
HOlson

Reputation: 31

Is there a way to programmatically delete rows across multiple sheets?

Is there a way to delete entire series of rows across every sheet in a Google Sheets?

I'm working with a document of approximately 70 sheets, and just received an error telling me I've maxed out on my allowed number of cells. However, I'm only using a very small portion of each sheet.

Is there a way to programmatically delete ALL Rows from 60 on across ALL sheets?

I know how to do it manually, but it seems like something that could and should be scripted.

Upvotes: 2

Views: 976

Answers (1)

Kriggs
Kriggs

Reputation: 3778

Yes, this can easily be scripted, in StackOverflow normally we show where we're stuck, but in this case is pretty simple, so...

function deleteRowsMax(){
  var ss = SpreadsheetApp.getActive(),
      sheets = ss.getSheets();

  for( i in sheets )
    sheets[ i ].deleteRows(61, sheets[ i ].getMaxRows() - 61);
}

Not tested but should work.

Upvotes: 2

Related Questions