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); }  } 

sample sheet - take copy

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); 

apps script documentation


Popular posts from this blog

php - How should I create my API for mobile applications (Needs Authentication) -

5 Reasons to Blog Anonymously (and 5 Reasons Not To)

Google AdWords and AdSense - A Dynamic Small Business Marketing Duo