How to Add Shortcut to Tab in Google Folder
Learn how to create shortcuts to specific tabs in Google Sheets using Google Drive and AppScript. This video covers two effective workarounds to link directly to tabs within your spreadsheets.
Can you actually put a link to a tab in a Google Drive? So, I've created a Google Drive folder and I'm going to show you a couple ways to do this that are pretty much workarounds, but they're fun and interesting way to dive into automation in AppScript. So, first off, I want to show you I have the sheet. This is just a general sheet. It has a few tabs. And no matter what tab I'm on, if I go up to file, I can go to this add shortcut to drive. And then I can choose a folder to actually add that in. So I can select this folder and add it. Now if I go back to my folder and I refresh, I have a link to that sheet. But is it to the tab? Let's double click on it and see. It's going to open just the sheet. It's not going to go to this tab. Before
I show you a really weird workaround, I'm going to show you how to add a redirect on this sheet. So I'm going to go up to extensions appscript. And here I'm going to write a function . go to new and curly brackets. What I want to do is I want to go actually to sales. So let's call this go to sales 2025 and I'm going to do spreadsheet app.get active spreadsheet get sheet by name. The name I'm going to do is the sales 2025 and all I'm going to do is activate with these parentheses at the end. So this function go to sales isn't going to do anything right now. If I click run, I will authorize it and it will work, but I want to be able to do it when the sheet is open. So, I'm going to click
run. Make sure you hit continue and authorize. And if I go to the sheet, it will activate that tab. But I want to run this when the sheet is open. So, I'm going to go over to the left side, go to triggers, go to the bottom right, add trigger , choose which function to run, go to sales 2025 from spreadsheet , and make sure my select event type is on open. Click save. Now when I go to this link, so the link is just going to open that and automatically it has brought me to the sales 2025. But see the thing about this is that it will happen to every single person who opens this sheet. Now once I get on the sheet, I can go to the other tabs. Totally fine. But what if I want to link directly to the tab in that drive? Well, up in the URL bar there is something called a GD.
And each sheet has one. So the very first sheet we created on this particular sheet has the G of zero and then this one has a GD of like some random numbers. Well, I can actually get another sheet to go to that URL. So I'm going to create a new sheet sheet new. I'm going to call this sheet redirect. And the URL that I want to go to is this URL which has the sheet ID and the GID which is the tab that very specific tab. So if I just go to this URL, it's going to open the spreadsheet and open that tab immediately without any automation. I don't need to have that open automation there. I can go directly to this tab. So how do I get this sheet to
direct me? Again, I'm going to go to appscript and go to create a little bit of appscript. So here we're going to create a function called go to link. We need a variable URL. We'll fill this in later, but it's just going to be quotes. And I need a variable HTML, which is HTML service.create HTML output. And here I'm going to write a little bit of script. So in bracket in these sort of angled brackets, I'm going to have a script. So I'm going to have a script. End the script just like HTML. I'm going to do window.open open and in quotes I'm going to have the URL have a semicolon google.script.host close and parenthesis and semicolon to
end that. So this URL here could be google.com but in fact we're going to end the single quotes and add some plus signs the URL. So this URL up here will be filled in here. Make sure we have that double quote around it. So, we have a double quote around this single quotes, but the single quotes are sort of saying, "Hey, put the text to the left and the right." And right here in the middle, we'll put the URL. We can set a width and a height. This is just a little pop-up that's going to show up uh while it's loading. And we'll do spreadsheet app. Get show modal dialogue. We need the HTML and we need some text. Opening link to tab. So all this is going to do is actually show up a modal and inside of that modal inside
of that like alert sort of area is a script that says hey go open this URL and then once that's open it's going to so we'll save this and I'm going to hit run here just so that I can authorize these things and I might be able to show you review permissions select all and continue opening link to tab and it has a blank one because we haven't put in the URL but let's say we want this particular URL. Paste that there. Save it. And again, if we hit run, go back here, it'll open a brand new sheet. Pretty cool, right? Again, how do we get this to run on open? Go to executions, go to triggers, click add trigger , choose which function to run, go to link, and on open, click save. Now, what I can do is this redirect sheet. I can
create a shortcut to the drive. Put it in direct to tab. Add. Let's go back to our folder. And we have two links, right? The link to me that was the direct link that once we open that sheet, it'll automatically move to the tab. But if we don't want that automation, we just want to go to the tab. We need to create another sheet that redirects. Open it up and we end up on the tab. I think this is a pretty cool workaround, pretty cool, interesting way to link to a specific tab. I showed you two ways in this video. Hopefully, one of those works for you. You're watching Better Sheets here on YouTube. Make sure you check out this video or this video and subscribe right now to get more tips, tricks, how-tos, get more out of your Google Sheets than you ever have before. I'm excited to be making a ton more videos here. Ask me
questions down in the comments and I will answer them in future videos. But for right now, right here, one of these videos is going to be your next Google Sheet.