I am trying to run a script on my spreadsheet that hides columns on one sheet based on whether a checkbox in another sheet is ticked.
I have created the below code but this doesn't seem to work:
function onEdit(){
var ss = SpreadsheetApp.getActiveSpreadsheet();
var sheet1 = SpreadsheetApp.getActive().getSheetByName('BALANCE SHEET');
var sheet2 = SpreadsheetApp.getActive().getSheetByName('OVERVIEW')
var cell = sheet2.getRange(7, 5);
if(cell == "TRUE"){
sheet1.hideColumns(21,2)};
if(cell == "FALSE"){
sheet1.showColumns(21,2)};
}
The tickbox is on the sheet OVERVIEW in cell E7 and I want this to hide columns V & W on the BALANCE SHEET.
When the tickbox is TRUE, I want the columns to be displayed and when the tickbox is FALSE the columns will be hidden.
Can anyone help on this please?