'Hiding Sheet in Workbook from certain people

I've started tampering with Google sheets recently. I cant seem to get the following script to actually do what I was hoping it would. Ideally I want it to allow certain users read/write access and certain users the inability to even see the sheet. I thought it would be possible but currently anyone can see the sheet.

function onOpen() {
  var adminUsers = ['[email protected]']

  if (adminUsers.indexOf(Session.getEffectiveUser().getEmail()) >= 0) {
    SpreadsheetApp.getActiveSpreadsheet().getSheetByName('Admin').showSheet()
  }

  if (Users.indexOf(Session.getEffectiveUser().getEmail()) >= 0) {
    SpreadsheetApp.getActiveSpreadsheet().getSheetByName('Admin').hideSheet()
  }
}


Solution 1:[1]

Google Sheets allows you to set permissions and hide without having to code anything. Simple select the drop down arrow on the sheet:

enter image description here

Those people you provide edit permissions will be able to find the hidden sheet(s), those without edit permissions will not be able to see the hidden sheet(s).

I hope this helps.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 konalion