Permalink
Browse files

Deleting all sheets from specified sheet number

Deletes the specified sheet number and all other subsequent sheets.
  • Loading branch information...
noemrd committed Mar 14, 2017
1 parent 0485c7e commit c0e8570f4ada867c024f3851f33dd6b5f10f311e
Showing with 15 additions and 2 deletions.
  1. +15 −2 script.gs
View
@@ -9,6 +9,7 @@ function onOpen() {
ui.createMenu('Spreadsheet Cleanup')
.addItem('Show Sheets', 'showSheets')
.addItem('Hide Sheets', 'hideSheets')
.addItem('Delete Sheets All Sheets From Sheet #', 'deleteAllSheetsFrom')
.addItem('Delete Sheets', 'deleteSheets')
.addItem('Copy Sheets', 'copySheets')
.addToUi();
@@ -22,21 +23,23 @@ function onOpen() {
var items = [
{name: 'Hide Sheets', functionName: 'hideSheets'},
{name: 'Show Sheets', functionName: 'showSheets'},
{name: 'Delete Sheets All Sheets From Sheet #', functionName: 'deleteAllSheetsFrom'},
{name: 'Delete Sheets', functionName: 'deleteSheets'},
{name: 'Copy Sheets', functionName: 'copySheets'},
];
ss.addMenu('Spreadsheet Cleanup', items);
}
}
function deleteSheets() {
var deleteSheetsContaining = Browser.inputBox("Delete sheets with names containing:");
deleteSheetsContaining = deleteSheetsContaining.toLowerCase();
deleteSheetsContaining = deleteSheetsContaining.toLowerCase();
if (sheetMatch(deleteSheetsContaining)){
for (var i = 0; i < sheetsCount; i++){
var sheet = sheets[i];
var sheetName = sheet.getName();
sheetName = sheetName.toLowerCase();
sheetName = sheetName.toLowerCase();
Logger.log(sheetName);
if (sheetName.indexOf(deleteSheetsContaining.toString()) !== -1){
Logger.log("DELETE!");
@@ -48,6 +51,16 @@ function deleteSheets() {
}
}
function deleteAllSheetsFrom() {
var deleteSheetsFrom = Browser.inputBox("Delete all sheet from sheet number:");
for (var i = deleteSheetsFrom -1 ; i < sheetsCount; i++)
{
ss.deleteSheet(sheets[i]);
}
}
function hideSheets() {
var hideSheetsContaining = Browser.inputBox("Hide sheets with names containing:");
if (sheetMatch(hideSheetsContaining)){

0 comments on commit c0e8570

Please sign in to comment.