How to Hide Many Tabs Automatically

Learn how to automatically hide and show multiple tabs in Google Sheets using Apps Script. This tutorial walks you through creating functions and a custom menu for easy access.

You want to hide many tabs automatically, meaning we have like template , instructions, settings down here on the bottom. We don't want to have to click and hide sheet each time for all of them. I'm going to show you how to do that with Apps Script . It's going to be very simple. I'll walk you through the exact Apps Script extensions, Apps Script . It's in your sheet already, the ability to code. So let's get coding. We're going to do two things. One, we're going to create the function that actually hides the sheets. We're also going to create a very simple menu that you can add to your sheets to allow you to access this Apps Script . We're gonna call it hide tabs. Click enter a few times and here we need spreadsheet app with capital S and a, capital A. Get active spreadsheet.

What this does is just gets the entire workbook that we're working in, get sheet by name here. We need to name the sheet that we want to hide template , and in coding we can change this code to a variable. We're gonna copy it and do. SS and do variable SS equals spreadsheet apps. So now every time we type Ss, it's going to be this code here. Now what do we wanna do with this sheet? We want to hide sheet and we need that parentheses at the end. We wanna do this for multiple sheets. We do ss do get sheet by name for instructions, hide sheet , and the same for settings. GetSheetByNameSettings. hideSheet. Command S for saving, or Save Project to Drive button up here next to Run. Now, if we want to test this, we can click Run

and see that it executes. The very first time you execute this, you have to authorize it. If we go back to our sheet, we see those sheets are hidden . Let's create one more. Function that shows these sheets, we don't want to have to unhide all of them at the same time. Show tabs, and all we have to do is change hide sheet to show sheet We've created two functions that we want to execute pretty simply but we don't want to have to come here and execute them inside of Apps Script . So we're going to create a function on open. I actually have this available for you at bettersheets. co slash snippets. You can copy this function right here. And what this does is it gets the UI code and creates a menu. We can name this menu, we're going to call it Automations. Automations. Just automations.

The first item is going to be whatever we want to show the user. So hide extra tabs and the second argument here in quotes is going to be the name of the function . So hide tabs. It has to be an exact match capitalization has to be exact for this to work. Second, show extra tabs. Thanks. And the item here will be show tabs again, has to be exactly the same. And this button will trigger this function . So hit save again, can click on the safe project to drive up here. I'm going to close this app script menu, and I'm going to refresh the sheet. When I refresh the sheet, it opens it again. Basically I can close that sheet and open it. I just need the action of opening to trigger that on open.

And here next to help, you'll see this automations menu and it has hide extra tabs and show extra tabs. So we'll show extra tabs. And there we have all of our tabs back again, template instructions and settings. Pretty cool, right? If you're looking to get more out of your Google sheets than you ever have before, get more app scripts, automations, subscribe here on YouTube to better sheets. or Become a member of BetterSheets. co and get all of these scripts for free over at BetterSheets. co.