4

I want to share the sheet with others but i also want them to not able to see some columns. Is there any way out to solve this using google apps script or if any alternate option for the same. Thank you.

4 Answers 4

12

You should take a look at the documentation, it will help you to find the function you're looking for. In this case, you need the Sheet.hideColumns(columnIndex) method

hideColumns(columnIndex)

Hides the column at the given index.

var ss = SpreadsheetApp.getActiveSpreadsheet(); var sheet = ss.getSheets()[0]; // Hides the first column sheet.hideColumns(1); 
Sign up to request clarification or add additional context in comments.

1 Comment

Thanks, actually i read somewhere on article saying you can not hide columns using google aaps script, so without even checking the documentation thoroughly i asked here. Sorry my bad !.
0
Very simple function function onOpen(){ ss = SpreadsheetApp.openById( 'sheetid' ), sheet = ss.getSheetByName('sheet_name'), ss.getActiveCell(); sheet.hideColumns(start_column_number, end_column_number); } 

2 Comments

Welcome to SO! You should add some additional explanation to your code to create a more robust answer. If you need additional help, check out how to answer.
Your answer is off. Should be: sheet.hideColumns(start_column_number, number_of_columns)
0

If the columns to be hidden are part of a merged column set, the hide columns methods don't work unless you hide all the columns in the merge.

Comments

0
sheet.hideColumns(y,x); 

y = start column number x = number of columns to be hidden

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.