Advertisement
Guest User

Untitled

a guest
Oct 16th, 2019
104
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.95 KB | None | 0 0
  1. // Adds the custom menu to the active spreadsheet.
  2. function onOpen() {
  3. var ui = SpreadsheetApp.getUi();
  4. ui.createMenu('Views')
  5. .addItem('Show All', 'showAll')
  6. .addItem('Contact Info for Paperwork', 'contactInfo')
  7. .addItem('Calendar View', 'calendarView')
  8. .addItem('Paperwork View', 'paperworkView')
  9. .addItem('Tasks View', 'tasksView')
  10. .addItem('Focus View', 'focusView')
  11. .addItem('Hostess View', 'hostessView')
  12. .addToUi();
  13. }
  14.  
  15.  
  16. // Define the showAll view which we will use in the menu and also inside of every other view
  17.  
  18. function showAll() {
  19. var spreadsheet = SpreadsheetApp.getActive();
  20. // Select all columns in the spreadsheet
  21. spreadsheet.getRange('A:AG').activate();
  22. // Show all columns
  23. spreadsheet.getActiveSheet().showColumns(spreadsheet.getActiveRange().getColumn(), spreadsheet.getActiveRange().getNumColumns());
  24. };
  25.  
  26. // Define the hide column function
  27. function hideColumn(columnLetter) {
  28. var spreadsheet = SpreadsheetApp.getActive();
  29. spreadsheet.getRange(columnLetter).activate();
  30. spreadsheet.getActiveSheet().hideColumns(spreadsheet.getActiveRange().getColumn(), spreadsheet.getActiveRange().getNumColumns());
  31. }
  32.  
  33. // Define all the other views
  34.  
  35. function contactInfo() {
  36. // First show all columns
  37. showAll()
  38. // Now hide the columns we don't want
  39. hideColumn('E:E')
  40. hideColumn('G:G')
  41. };
  42.  
  43. function calendarView() {
  44. // First show all columns
  45. showAll()
  46. // Now hide the columns we don't want
  47. hideColumn('E:F')
  48. };
  49.  
  50.  
  51. function paperworkView() {
  52. // First show all columns
  53. showAll()
  54. // Now hide the columns we don't want
  55. hideColumn('E:F')
  56. };
  57.  
  58.  
  59. function tasksView() {
  60. // First show all columns
  61. showAll()
  62. // Now hide the columns we don't want
  63. hideColumn('E:F')
  64. };
  65.  
  66.  
  67. function focusView() {
  68. // First show all columns
  69. showAll()
  70. // Now hide the columns we don't want
  71. hideColumn('E:F')
  72. };
  73.  
  74.  
  75. function hostessView() {
  76. // First show all columns
  77. showAll()
  78. // Now hide the columns we don't want
  79. hideColumn('E:F')
  80. };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement