0
votes

Can you please help me to make a custom script so that i can hide and show a specific nameRanged in Google Spreadsheet.

This is the sample code that im using:

function onOpen() {
   var menu = [{name: "Hide Daily Columns", functionName: "hideColumns"}, {name: "Show Daily Columns", functionName: "showColumns"}]

SpreadsheetApp.getActiveSpreadsheet().addMenu("My Views", menu); }

var ss = SpreadsheetApp.getActiveSpreadsheet();
var sheet = ss.getActiveSheet();
var name = ss.getRangeByName("sample1");


function hideColumns() {
sheet.hideColumn(name);

}
function showColumns() {
sheet.showColumns(Name);
} 

Note: the problem here is the .showColumns there's error promp. Cannot convert range into class.

Thanks!

1

1 Answers

0
votes

showColumns does not accept a range. Change it to unhideColumn which will accept a range. Like this:

function showColumns() {
  sheet.unhideColumn(name)
}