Skip to content

Instantly share code, notes, and snippets.

@meetpahul
Created April 28, 2022 08:45
Show Gist options
  • Select an option

  • Save meetpahul/80bdb3d597a484031b17741c3ae4c1a3 to your computer and use it in GitHub Desktop.

Select an option

Save meetpahul/80bdb3d597a484031b17741c3ae4c1a3 to your computer and use it in GitHub Desktop.
// Deletes sheets whose names contain the criteria string. Takes Spreadsheet URL and Criteria-string as arguments.
function cleanSheets(url, criteriaString){
var ss = SpreadsheetApp.openByUrl(url)
var sheets = ss.getSheets()
for (var i=0; i<sheets.length; i++){
var sheetName = sheets[i].getSheetName();
if (sheetName.indexOf(criteriaString)>-1) {ss.deleteSheet(sheets[i])}
}
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment