Last active
March 2, 2020 17:04
-
-
Save TaylorJadin/56a3c209e815ee3a8620342abef2c7d2 to your computer and use it in GitHub Desktop.
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
// Adds the custom menu to the active spreadsheet. | |
function onOpen() { | |
var ui = SpreadsheetApp.getUi(); | |
ui.createMenu('Views') | |
.addItem('Show All', 'showAll') | |
.addItem('Contact Information View', 'contactInfoView') | |
.addItem('Calendar View', 'calendarView') | |
.addItem('Paperwork View', 'paperworkView') | |
.addItem('Tasks View', 'tasksView') | |
.addToUi(); | |
} | |
function showAll() { | |
var spreadsheet = SpreadsheetApp.getActive(); | |
// Select all columns in the spreadsheet | |
spreadsheet.getRange('A:CH').activate(); | |
// Show all columns | |
spreadsheet.getActiveSheet().showColumns(spreadsheet.getActiveRange().getColumn(), spreadsheet.getActiveRange().getNumColumns()); | |
}; | |
// Define the hide column function | |
function hideColumn(columnLetter) { | |
var spreadsheet = SpreadsheetApp.getActive(); | |
spreadsheet.getRange(columnLetter).activate(); | |
spreadsheet.getActiveSheet().hideColumns(spreadsheet.getActiveRange().getColumn(), spreadsheet.getActiveRange().getNumColumns()); | |
} | |
// Define all the other views | |
function contactInfoView() { | |
// First show all columns | |
showAll() | |
// Now hide the columns we don't want | |
hideColumn('A:A') | |
hideColumn('C:E') | |
hideColumn('I:I') | |
hideColumn('N:O') | |
hideColumn('P:Q') | |
hideColumn('T:AB') | |
hideColumn('AD:AJ') | |
hideColumn('AO:CH') | |
}; | |
function calendarView() { | |
// First show all columns | |
showAll() | |
// Now hide the columns we don't want | |
hideColumn('A:A') | |
hideColumn('J:AH') | |
hideColumn('AI:AM') | |
hideColumn('AP:CH') | |
}; | |
function paperworkView() { | |
// First show all columns | |
showAll() | |
// Now hide the columns we don't want | |
hideColumn('A:A') | |
hideColumn('C:E') | |
hideColumn('I:AH') | |
hideColumn('AI:AM') | |
hideColumn('BD:CH') | |
}; | |
function tasksView() { | |
// First show all columns | |
showAll() | |
// Now hide the columns we don't want | |
hideColumn('A:A') | |
hideColumn('C:E') | |
hideColumn('H:BC') | |
hideColumn('BK:CH') | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment