Skip to content

Instantly share code, notes, and snippets.

@cms-jakes
Created December 7, 2016 18:57
Show Gist options
  • Select an option

  • Save cms-jakes/9c3ea279910b4e0e0611ceb1a7e7997e to your computer and use it in GitHub Desktop.

Select an option

Save cms-jakes/9c3ea279910b4e0e0611ceb1a7e7997e to your computer and use it in GitHub Desktop.
function deleteExtraColsAndRows() {
var ss = SpreadsheetApp.getActiveSheet()
//Columns
var lastCol = ss.getLastColumn();
var endc = ss.getMaxColumns();
try{
ss.deleteColumns(lastCol+1, endc-lastCol);
}catch(e){Logger.log('col error: '+e)}
//Rows
var lastRow = ss.getLastRow();
var endr = ss.getMaxRows();
try{
ss.deleteRows(lastRow+1,endr-lastRow);
ss.insertRowsAfter(lastRow, 10);
}catch(e){Logger.log('row error: '+e)}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment