Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Adds the custom menu to the active spreadsheet.
- function onOpen() {
- var ui = SpreadsheetApp.getUi();
- ui.createMenu('Views')
- .addItem('Show All', 'showAll')
- .addItem('Contact Info for Paperwork', 'contactInfo')
- .addItem('Calendar View', 'calendarView')
- .addItem('Paperwork View', 'paperworkView')
- .addItem('Tasks View', 'tasksView')
- .addItem('Focus View', 'focusView')
- .addItem('Hostess View', 'hostessView')
- .addToUi();
- }
- // Define the showAll view which we will use in the menu and also inside of every other view
- function showAll() {
- var spreadsheet = SpreadsheetApp.getActive();
- // Select all columns in the spreadsheet
- spreadsheet.getRange('A:AG').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 contactInfo() {
- // First show all columns
- showAll()
- // Now hide the columns we don't want
- hideColumn('E:E')
- hideColumn('G:G')
- };
- function calendarView() {
- // First show all columns
- showAll()
- // Now hide the columns we don't want
- hideColumn('E:F')
- };
- function paperworkView() {
- // First show all columns
- showAll()
- // Now hide the columns we don't want
- hideColumn('E:F')
- };
- function tasksView() {
- // First show all columns
- showAll()
- // Now hide the columns we don't want
- hideColumn('E:F')
- };
- function focusView() {
- // First show all columns
- showAll()
- // Now hide the columns we don't want
- hideColumn('E:F')
- };
- function hostessView() {
- // First show all columns
- showAll()
- // Now hide the columns we don't want
- hideColumn('E:F')
- };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement