DEV Community

gDevTest
gDevTest

Posted on

How to Hide/unhide columns with google AppsScript

Hello,
I'm a beginer in js & google apps script and trying to get this done to no avail...
I've divided my google sheet in 3 working zones [Range1(E:I), Range2(J:N), Range3(O:S)]
so, I'm trying to write a script to hide and unhide each range in the way that
if Range1 is showing/unhidden, Range2 & Range3 should be hidden and so should it be for the other 2 ranges...
The script I tried to write(see below) for Range1 returns no error; but won't do anything either

Please your contribution and help will be apprciated...

=============

function hideRange1(){
var wb= SpreadsheetApp.getActiveSpreadsheet();
var sh= wb.getActiveSheet();
var range1= homesh.getActiveRange(E:I);

if (range1.getA1Notation() !="E1:I") return;

if(range1=="True"){
SpreadsheetApp.getActiveSpreadsheet().getActiveSheet().hideColumns(10, 19);

}
else if (range1 == "FALSE") {
SpreadsheetApp.getActiveSpreadsheet().getActiveSheet().showColumns(10, 19);
}
}

Top comments (0)