Last active
September 21, 2017 07:30
-
-
Save ryanpraski/7b6fa5a2c73eec8d4e19 to your computer and use it in GitHub Desktop.
Google Sheet Script removeEmptyRows removeEmptyColumns
This file contains 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