SheetLord Update: duplicate tab and automatically add Search Term

About this Tutorial

Updated SheetLord with a new function.

Video Transcript

0:00 Just had the request to add an automatic duplicator, so one of the features of SheetLord here, where we have one keyword and then we have a bunch of awesome links that we can copy and paste and open with multiple links, is we want to save a sheet or two, right, so if we search for something and we're
0:20 like, oh, we want to search for this again, this Google Sheets keyword, we want to duplicate and add here, Google Sheets, but we can get Apps Script to do this for us, so let's delete this and do that with Apps Script, let's go to extensions, Apps Script, we have our functions here, we have function 
0:46 reset checkboxes and on open like this. Let's create another function, duplicate, and we want to add it to our on open, so we can add a new row here and call this duplicate, and we'll say duplicate current sheet, and So here's a few things we need, we need variable.
1:12 Key word, that's going to be equals spreadsheet app dot get active sheet, get range, and that's going to be B2, for right now, B2, get value.
1:29 So now we know the key word, now we just need to create a new sheet, well we need one more thing we need very variable, SS equals spreadsheet app dot get active spreadsheet, this is the entire spreadsheet that exists right now, so we're going to go SS dot get, get sheet by name, actually sorry, we are
1:53 going to do SpreadsheetApp.getActiveSheet.getActiveSheet. copy to, and we're going to copy it to the spreadsheet that we're in, so just use SS.
2:07 Let's move this up a little bit to the middle of the screen, and then we're going to set name to, well we need actually two things, right?
2:17 We need the name of the sheet we're on right now, Machine name equals, we're going to get the add. Active sheet again, get name, so we can get that sheet name, plus, and then we'll put a colon, a space, and then a plus, keyword.
2:41 Let's save this, and now to get it in the, on open, we need to close Apps Script, and we need to refresh our sheet or close it.
2:48 Close it and open it again, so we're on search, search lord menu up here on the top right, duplicate current sheet, now we have it, done.
3:01 So some extra things we could do to make this a little bit better is maybe we don't want to duplicate about sheets or how to use.
3:10 Maybe we only want to duplicate it when we're on search or search some, so we will, we get the name here, so if sheet name is equal to search or two pipes is the or sheet name is equal to search some, and then we'll put this function in curly brackets, and we'll only put this here.
3:48 Let's format document, else, we will give a little message, so spreadsheet app dot get active sheet Thank you. Spreadsheet app dot get active toast can only copy search and search some, or, and let's capitalize this just to keep it the same search some, there we go, so now we're duplicating the sheet
4:22 , adding the keyword, and, doing that from this search lord menu, so if we're on how to use, let's duplicate current sheet, can only copy search or search some, perfect, that allows us to add maybe some more sheets here later on if we need to, if we're adding more sheets, more ways to search, pretty 
4:45 cool, right? that was a way to automatically duplicate. a sheet based on user needs.