Skip to content

Instantly share code, notes, and snippets.

@phillypb
Created April 1, 2022 09:43
Show Gist options
  • Save phillypb/409bfcb8e7d33b8023926cb3d1825bce to your computer and use it in GitHub Desktop.
Save phillypb/409bfcb8e7d33b8023926cb3d1825bce to your computer and use it in GitHub Desktop.
/** * @OnlyCurrentDoc */
function moveColumns() {
// get sheet
var sheet = SpreadsheetApp.getActiveSheet();
// select columns to be moved ('collegename' & 'shoesize')
var columnsToMove = sheet.getRange("E1:F1");
// move columns to the left of 'postcode'
sheet.moveColumns(columnsToMove, 4);
}
/*
This Function creates a menu item to run this script.
*/
function onOpen() {
SpreadsheetApp.getUi()
.createMenu('Admin')
.addItem('Move Columns', 'moveColumns') // label for menu item, name of function to run.
.addToUi();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment