There is a deleteRows() method that allow you to delete multiple rows at once:
https://developers.google.com/apps-script/reference/spreadsheet/sheet#deleterowsrowposition-howmany - Eric On Thursday, March 17, 2016 at 6:50:59 AM UTC-7, [email protected] wrote: > > So we know that we can run this to delete rows 1 by 1: > > function clear() { > var sheet = SpreadsheetApp.getActive().getSheetByName('Name of Sheet'); > var rows = sheet.getDataRange(); > var numRows = rows.getNumRows(); > for (var row=numRows; row > 1; row--) { > sheet.deleteRow(row); > } > } > > > but is there a faster way? how do i just delete all rows except the first > one? > > if i have 5000 rows, this takes like 30 minutes. Looking for a faster way. > Of course, manually i can just select all rows, right click, delete, and 1 > second, DONE. but how do i script this? > > please help thank you! > > > -- You received this message because you are subscribed to the Google Groups "Google Spreadsheets API" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. For more options, visit https://groups.google.com/d/optout.
