I do not code program in javascript but I managed to find the script below online which allows me to hide one range of columns. Problem is I need to be able to repeat this for multiple ranges of columns in one sheet. so I can hide/show columns C-AG with one button and separately hide/show columns AI - BJ with another button (and do this for multiple months). This is for appointments with lots of data so I can easily hide and show each month of appointments.
Please see below images this demonstrates the functionality. (First image shows January shown, second shows January hidden.)
Spreadsheet before running hide script -
Spreadsheet after running hide script
Please also see image of custom menu that this script puts in my toolbar. Within this menu is two buttons, first is Show C-AG second is Hide C-AG.
This is the script which allows me to hide/show one range of columns (C-AG) and works well but is limited to only one group of columns (one month):
function onOpen() {
var menu = [{name: "Show C-AG", functionName: "showColumns"}, {name: "Hide C-
AG", functionName: "hideColumns"}]
SpreadsheetApp.getActiveSpreadsheet().addMenu("Custom", menu);
}
function showColumns() {
var ss = SpreadsheetApp.getActiveSpreadsheet();
var sheet = ss.getActiveSheet();
sheet.showColumns(3,31); // C-AG, 31 columns starting from 3rd
}
function hideColumns() {
var ss = SpreadsheetApp.getActiveSpreadsheet();
var sheet = ss.getActiveSheet();
sheet.hideColumns(3,31); // C-AG, 31 columns starting from 3rd
}
Thank you in advance for any help on this, and apologies if my question is too vague and feel free to tell me to add more info/description if necessary.