Get Tab Name in Cell
Learn how to get the tab name in a cell using a custom function in Google Sheets. This video walks you through the steps to create a simple app script that retrieves the active sheet's name.
Hey, let's get the tab name in a cell. So this seems pretty straightforward. We have a tab and we have the name of the tab. And for every tab in our spreadsheet , it has a different name. And we can edit this name, like we can go in here, double click and write this sheet. And we can name these for many different things. Sometimes we wanna print a sheet out. We want this tab. Name somewhere. So, but we want it in a nice way so we can create print friendly tab names, or we want to share some context aware sort of status or instructions. And we need to get the tab name into a cell, but sometimes we also want to add that tab name that we edit into row data . Maybe we're aggregating everything, we're taking all of the sheets in a,
in a, across the spreadsheet and we're putting it all in one sheet, but we wanna. No, what tab did that data come from? So this is how we do it. We're going to create a custom function actually here. 'cause when we go to equals tab name, there's nothing tab sheet, there's, there's no formula for it. But we'll create our own. It's actually very quickly we can do this. Extensions apps. So you two and your sheet have this app script . We're gonna rename it This sheet, we're gonna rename this function tab name, and all we're gonna do is return spreadsheet app dot get active sheet , get name. We're gonna get that name. That has to be, and I wanna make sure you get this right. Capital A and S for Active Sheet and Capital N. Forget name and we have to have the parentheses. Let's save that.
But we wanna do one more thing, which actually let's create this as a custom function . We'll just add a slash and two stars and say, at custom function . Why? Because that actually turns it into a function we can get with auto complete. I'll show you. So let's go to our B one where we want to put the sheet name equals tab and there it is, tab name. Well, and that parentheses it's loading and it says the sheet. So now it cell B one has the name of the sheet here. Let's create another sheet and say call this another sheet. And you see it says copy of the sheet, which is the original name of the tab. So this doesn't really auto populate, but we do have the ability to delete it and add it again
and it'll load again. And there it is. There's a name of the sheet. Will this auto update, this should auto update at some particular time. It could take five minutes, 10 minutes, 15 minutes, but it should auto update eventually. Or you can just reload the sheet or reload the. Cell. There you go. That's how to get the tab name in the cell. Just app script . Return spreadsheet . App duck. Get active sheet . Duck get name. You are 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 gonna
be your next Google sheet.