Reputation: 1
I just start learning about google script a few days ago and I'm facing one problem that I can't solve. In my google sheet I want to hide columns C-K if cell B2=FALSE and show columns C-K if cell B2=TRUE. How can I do that?
Upvotes: 0
Views: 2992
Reputation: 64042
Add a checkbox to Cell B2 and use this simple onEdit function.
function onEdit(e) {
var sh=e.range.getSheet();
if(sh.getName()=='Sheet234' && e.range.columnStart==2 && e.range.rowStart==2) {
e.source.toast(e.value);
if(e.value=="TRUE") {
sh.hideColumns(3,9);
}else{
sh.showColumns(3,9);
}
}
}
Animation:
Upvotes: 3