Forked from ryanpraski/google_sheet_script_removeEmptyRows_removeEmptyColumns.js
Created
September 21, 2017 07:30
-
-
Save kobeumut/5378d9b3a5778981851838c1b28f0b0f to your computer and use it in GitHub Desktop.
Google Sheet Script removeEmptyRows removeEmptyColumns
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Remove All Empty Columns in the Entire Workbook | |
function removeEmptyColumns() { | |
var ss = SpreadsheetApp.getActive(); | |
var allsheets = ss.getSheets(); | |
for (var s in allsheets){ | |
var sheet=allsheets[s] | |
var maxColumns = sheet.getMaxColumns(); | |
var lastColumn = sheet.getLastColumn(); | |
if (maxColumns-lastColumn != 0){ | |
sheet.deleteColumns(lastColumn+1, maxColumns-lastColumn); | |
} | |
} | |
} | |
//Remove All Empty Rows in the Entire Workbook | |
function removeEmptyRows() { | |
var ss = SpreadsheetApp.getActive(); | |
var allsheets = ss.getSheets(); | |
for (var s in allsheets){ | |
var sheet=allsheets[s] | |
var maxRows = sheet.getMaxRows(); | |
var lastRow = sheet.getLastRow(); | |
if (maxRows-lastRow != 0){ | |
sheet.deleteRows(lastRow+1, maxRows-lastRow); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment