Members-only tutorial
Watch the video and get the practice sheet with membership.
About this Tutorial
Sheet Resources
Video Transcript
<div>0:01 So, hello. In this video, you're going to learn how to duplicate Learn how to duplicate a tab in Google Sheets effortlessly. Opens in new tab a tab and move it to the end in Google Sheets automatically.<br>0:07 So here's a few things that we have already. We already have some Apps Script Discover how Apps Script can automate your Google Sheets tasks. Opens in new tab , uh, created that's in Extensions Apps Script Explore how to access Apps Script through Google Sheets extensions. Opens in new tab .<br>0:15 We've created a menu here that just has two items. Uh, it's going to move a tab to the far right or far left.<br>0:23 This is in a previous video, and it's a very simple code.
It's just saying, get the active spreadsheet Understand what the active spreadsheet means in Google Sheets. Opens in new tab , the entire file, It's going out how many total sheets there are and move the current active sheet Find out what the active sheet is and how to work with it. Opens in new tab to the end, that's the far right, with this total number Learn about using numbers in Google Sheets functions and scripts. Opens in new tab of sheets.<br>0:39 It's just moving it there. But if you want to move it to the far left, we're just going to move the active sheet Find out what the active sheet is and how to work with it. Opens in new tab to number Learn about using numbers in Google Sheets functions and scripts. Opens in new tab one, the first position of the total sheets.<br>0:48 But let's add to this. We want to create a script that takes this template Get insights on creating and using templates in Google Sheets. Opens in new tab , copies it, it's going to rename it to today's date.<br>0:56 And then, one issue is, if we duplicate Learn how to duplicate a tab in Google Sheets effortlessly. Opens in new tab this ourselves.
Let's duplicate Learn how to duplicate a tab in Google Sheets effortlessly. Opens in new tab it and rename it November 7th. There we go.<br>1:06 Ah, now let's do that again. Gonna see something happen. Duplicate Learn how to duplicate a tab in Google Sheets effortlessly. Opens in new tab . It's going to create the duplication right next to the template Get insights on creating and using templates in Google Sheets. Opens in new tab .<br>1:16 So the point of this video is how do we create this template Get insights on creating and using templates in Google Sheets. Opens in new tab , or duplicate Learn how to duplicate a tab in Google Sheets effortlessly. Opens in new tab , of the template Get insights on creating and using templates in Google Sheets. Opens in new tab , and then move it all the way to the far right at the same time.<br>1:28 So let's call this November 6th. And let's just delete the sales data Explore how to manage and manipulate data in Google Sheets. Opens in new tab here. Maybe it is a real template Get insights on creating and using templates in Google Sheets. Opens in new tab and we want to put in that sales data.<br>1:38 Hit there.
Okay, let's go back to our script and write a new script calling, ah, to duplicate Learn how to duplicate a tab in Google Sheets effortlessly. Opens in new tab that template Get insights on creating and using templates in Google Sheets. Opens in new tab . We're going to say function Understand how to create and use functions in Google Sheets. Opens in new tab duplicate Learn how to duplicate a tab in Google Sheets effortlessly. Opens in new tab template Get insights on creating and using templates in Google Sheets. Opens in new tab .<br>1:53 I'm going to add some bars, we're going to say const ss equals spreadsheet Learn the basics of working with spreadsheets in Google Sheets. Opens in new tab app. dot get active spreadsheet Understand what the active spreadsheet means in Google Sheets. Opens in new tab . That's just calling the entire spreadsheet Learn the basics of working with spreadsheets in Google Sheets. Opens in new tab file.<br>2:06 We're also going to need template equals ss dot get sheet by name and we're going to call this template. That is just the name of the sheet that we want to copy.<br>2:23 Now we want to get today's date. const today equals new date we can format this if we want.
Let's say const today string Discover how to work with strings in Google Sheets formulas. Opens in new tab equals utilities dot format Get tips on formatting your data in Google Sheets for better clarity. Opens in new tab date today.<br>2:42 And what format Get tips on formatting your data in Google Sheets for better clarity. Opens in new tab do we want it in? Want it in GMT minus six time zone Understand how time zones affect date and time in Google Sheets. Opens in new tab and let's put it in year year year hyphen m m hyphen day day.<br>3:00 Let's put it in that format Get tips on formatting your data in Google Sheets for better clarity. Opens in new tab . We can change that format Get tips on formatting your data in Google Sheets for better clarity. Opens in new tab just by changing this text here. All right. Now we need to actually copy it.<br>3:08 Uh, we're going to use, let's create a new sheet. New sheet equals template Get insights on creating and using templates in Google Sheets. Opens in new tab dot copy two. And we're going to copy it to the spreadsheet Learn the basics of working with spreadsheets in Google Sheets. Opens in new tab .<br>3:25 We want to set the name. So new sheet dot set name.
And we're going to set it as the string Discover how to work with strings in Google Sheets formulas. Opens in new tab of today.<br>3:36 And now we need to make sure that this is the active sheet Find out what the active sheet is and how to work with it. Opens in new tab . Yes, yes.<br>3:51 And we want to set active sheet Find out what the active sheet is and how to work with it. Opens in new tab as the new sheet. And now, once that's the active sheet Find out what the active sheet is and how to work with it. Opens in new tab , we can actually call this function Understand how to create and use functions in Google Sheets. Opens in new tab here, moveTab, right.<br>4:11 So let's see this in action. I want to add item here. Uh, we're going to call it duplicateTemplate. And we're going to send it to duplicate Learn how to duplicate a tab in Google Sheets effortlessly. Opens in new tab template Get insights on creating and using templates in Google Sheets. Opens in new tab function Understand how to create and use functions in Google Sheets. Opens in new tab .<br>4:29 See this name here? Matches this function name here.
Once we have that done, we will refresh our sheet so that our custom menu Learn how to create custom menus in Google Sheets for easy access. Opens in new tab will show up here next to help.<br>4:40 And now let's see if this works. We will need authorize first. And now we have today's date. And it is to the far right.<br>4:50 So we can go back to template Get insights on creating and using templates in Google Sheets. Opens in new tab . Let's, uh, rename this to something else, something else. And test it again. go up to custom menu Learn how to create custom menus in Google Sheets for easy access. Opens in new tab , do duplicate Learn how to duplicate a tab in Google Sheets effortlessly. Opens in new tab template Get insights on creating and using templates in Google Sheets. Opens in new tab .<br>5:03 It's running the script and it's moving it to the far right and it is copying that template Get insights on creating and using templates in Google Sheets. Opens in new tab .
Doing everything we want.<br>5:09 So to refresh, or review rather, we have created an unopened function Understand how to create and use functions in Google Sheets. Opens in new tab that creates our custom menu Learn how to create custom menus in Google Sheets for easy access. Opens in new tab . We have created a function Understand how to create and use functions in Google Sheets. Opens in new tab that copies the duplicates the template Get insights on creating and using templates in Google Sheets. Opens in new tab and renames it as a formatted date.<br>5:28 And then Then it calls this other function Understand how to create and use functions in Google Sheets. Opens in new tab , moveTabToFarRight, where which that one is just setting whatever active spreadsheet Understand what the active spreadsheet means in Google Sheets. Opens in new tab it is to the position of the number Learn about using numbers in Google Sheets functions and scripts. Opens in new tab of total sheets.<br>5:39 So that's going to be moving it to the far right.
If we, however, want to create a, uh, duplicate Learn how to duplicate a tab in Google Sheets effortlessly. Opens in new tab and move it to tab to the far left, we just use this function Understand how to create and use functions in Google Sheets. Opens in new tab here, moveTabToFarLeft, instead of far right.<br>5:52 So there you go. We've created a duplicate Learn how to duplicate a tab in Google Sheets effortlessly. Opens in new tab and moved it to the end of the Google Sheet. Enjoy.</div>