google apps script - sheet.deleteRows() Need to delete all the rows with data from top (preferably 2nd row) -
200-300 rows of data need deleted every day. click of menu item, want delete these rows. have script seems working partially (it deleting few rows..gettinn out of bounds error) , pretty slow should say. hoping can shed light on speeding process or give new code design,
** if possible exclude row_1
function clearrange() { var sheet = spreadsheetapp.getactive().getsheetbyname('test'); var start=1; var end=300; (var = start; <= end; i++) { sheet.deleterow(i); } }
don't use for
loop. can in 1 line:
var start, end; start = 2; end = sheet.getlastrow() - 1;//number of last row content //blank rows after last row content not deleted sheet.deleterows(start, end);