Members-only tutorial
Watch the video and get the practice sheet with membership.
About this Tutorial
Sheet Resources
Video Transcript
<div>0:00 I want to show you how to insert multiple rows in Google Sheets . We're going to show you the easy way and a hard way with automation, some way you can automate inserting rows.<br>0:10 And we're going to have a few problems along the way that I'm going to share with you as solutions, like formatting .<br>0:16 For instance, there is a very simple way to insert multiple rows. How To Add Columns in Google Sheets Automate Google Sheets With Zero Experience Insert Row Daily Automatically
If you go all the way down to the bottom command down arrow, and you see add 1,000 rows, you can just click add and you can add 1,000 rows at a time.<br>0:29 You can even add one row at a time if you just click here. If you go up to the top and you're like hey, I don't really want to add rows to the bottom, I'd rather add rows to the top, you can select a couple of rows.<br>0:40 Select rows, add, and then right click and insert two rows above or below. How To Add Columns in Google Sheets How To Insert Row Under Header Automatically
And that will insert the rows there.<br>0:49 Something interesting is going to happen here and I want to show you right now what that is and how to avoid it.<br>0:54 So if we have some formatting here, we're going to format this with some background color , just yellow. And that's all And then I insert a row below.<br>1:02 Notice that the background color is copied. Writer Better Prompts Alternate Row Color Automatically
So the formatting of whichever row you're adding to, remember adding to, that is the row that's going to copy the formatting .<br>1:13 So, if I go down to row 3, the one under it, and I insert row above, you notice the row inserted does not have the formatting above it, it's the one from below it because we're adding one above it.<br>1:25 So, whichever one you're adding from, it's going to copy that formatting . How To Insert Row Under Header Automatically
Which is actually very useful, especially if you have drop-down menus and you have formatting you want to actually copy.<br>1:36 Um, and if you want to make a bigger header row , go up to the header . Insert row below or above here, and you're going to copy that header .<br>1:44 But for now we want to delete these rows here and here, and we just want header and we want some data .<br>1:51 Now, I showed you a few ways to add rows, right? Sheet Makeover - Google Ad Writer How To Insert Row Under Header Automatically
We insert a row, we select a row, insert any number of rows you want to enter, and you're going to be able to enter them or add them.<br>2:03 And you can scroll down and add rows there. But let's see, let's say we want to do this programmatically. So we're going to go to extensions app script .<br>2:10 We're going to write a little bit of code here, and we're going to insert multiple rows, uh, at the click of a button.<br>2:17 Maybe we want to specifically add five rows every single time we click a button. How To Add Columns in Google Sheets Add Columns Automatically Insert Row Daily Automatically
So let's call this project insert rows .<br>2:27 We're going to call this function insert five rows. First we need a custom menu actually. We get this at betasheets.co slash snippets slash custom menu two functions .<br>2:38 We're going to copy this. And we're going to insert it above here. So when our ah sheet is opened, we'll have some automations here.<br>2:48 The first item is going to be insert five rows. We'll call that function function insert five rows. We'll call that function when we hit insert five rows.<br>3:00 We're going to delete the second function for now. Spreadsheets Explained over 5 Levels of Difficulty Custom Menu - 1 Function How To Insert Row Under Header Automatically
And what we want to do is, we need spreadsheet .app.getactivespreadsheet.getsheet. Uh, actually we don't need active spreadsheet .<br>3:14 We want active sheet , whichever sheet we're on, get active sheet , get range . I think we can do, actually no, we just need to do insert rows .<br>3:26 So we want to insert rows after or before. There are two different functions , and just like I mentioned earlier in this video, it depends what we're trying to do.<br>3:35 If we are trying to add header rows, we want to use this after one. Getting Started Coding in Apps Script Activate A Certain Sheet When Opening a Spreadsheet How To Insert Row Under Header Automatically
But if we want to, insert rows under the header but have the same formatting as the data here, we're going to need to insert rows before.<br>3:49 And what we're gonna need is just the number of rows and and where they go. So before two, which is the second row.<br>4:00 And we want to add five rows. So let's save this, command s, once that orange button goes away. We can now close this and we're gonna refresh our sheet or actually reopen it so that we get our custom menu here, our automations menu.<br>4:17 It'll show up once Apps Script is added. There it is. Getting Started Coding in Apps Script Add Columns Automatically How To Insert Row Under Header Automatically
We have an automations menu and on this sheet that we have, we can insert five rows.<br>4:27 We need to authorize first. Once it's authorized, we can actually hit insert five rows. See the script is running and inserts five rows with the formatting from that second row.<br>4:38 Now let's change this to show you a row. I'm what I mean. What Can You Automate in Google Sheets? Every single trigger available to Google Sheet users Basic CRM - Add a Powerful Script To Move Row Based on Status How To Insert Row Under Header Automatically
I can tell you as long as I can tell you but I, I think showing you is going to hit home what happens.<br>4:46 So if we instead do insert rows after and we select one, because this is going to be the first intuitive thing you think about.<br>4:57 You think oh I want to insert a row under the header row . So I want to insert after one. So now the same function is going to do exactly the same thing but it's going to insert row after one, five of them.<br>5:09 So let's see, insert five rows, what happens? There you go. Writer Better Prompts How To Insert Row Under Header Automatically
So these all share the formatting of the row it's been inserted under.<br>5:18 So we don't want to do that. What we want to do is insert. is insert rows before. And maybe we don't want five but maybe we want one every single day.<br>5:30 So we'll call this insert five rows. We can copy this function and we're going to call this insert one row.<br>5:38 And we're going to insert before. Before two. Make sure it's before two. We're only going to insert one row. Writer Better Prompts How To Insert Row Under Header Automatically
And let's add that item here to our automations menu.<br>5:50 We don't need to do this to add a trigger but we just want it just in case we want to ah do this manually.<br>5:56 So we'll do insert one row. So this spelling here has to be exactly the spelling here in this function . Now, to automate this and do it every single day, you know, at 6am or 5am before we work, we want to insert a row here so we enter our information, whatever information we want to add.<br>6:14 Maybe we're doing timekeeping, time tracking, project management, maybe we're adding data entry every single day. What Can You Automate in Google Sheets? Every single trigger available to Google Sheet users Automatic Calculations Insert Row Daily Automatically
Uh, and anytime we do this, we want to make sure that we have the correct function .<br>6:26 So let's just refresh this sheet again and make sure that even manually, once we open this and manually, it's going to do the right thing.<br>6:36 So let's actually delete all of this so we can see it. Let's go to our extensions app script again and we're going to need to create a trigger .<br>6:55 Over on the left side, you see this button triggers. On the bottom right, add a trigger . Choose which function to run.<br>7:03 We're going to insert one row. Automate Emails What Can You Automate in Google Sheets? Every single trigger available to Google Sheet users Automatic Calculations Insert Row Daily Automatically
The event source in this case is going to be time-driven. We are going to do every day, so we need a day timer.<br>7:11 We're going to do it in the morning between 5am and 6am. We only get to choose an hour out of the day.<br>7:17 We don't get to choose a very specific time if we want to do this every day. What will happen is it will do a random time, but then after that it will go every 24 hours.<br>7:27 So we'll do 5am to 6am, save, and now every single day between 5am and 6am, one row will be inserted.<br>7:36 We can see this insert row here. If we have any errors, it may email us. Email Yourself a Cell from a Google Sheet, Every Day Insert Row Daily Automatically
If we do not want to continue using this, we can always go over here to 3 buttons and click delete trigger .<br>7:47 We can also edit it if we want to say do it ah every week or maybe every hour, depending on what you want to do.<br>7:56 So we can edit it as well. Let's save that and just go ahead. and delete it. Automatically Clear Content | Refresh Reuse Recycle Templates How to Prevent Delete Tab
So I've shown you how to automatically, which is a hard way, automatically insert multiple rows or any number of rows anywhere in your sheet and I've shown you how to do this manually which is select some cells or some rows,<br>8:14 insert a row, or go all the way down, command down arrow ah to the bottom and add some rows.</div> How To Add Columns in Google Sheets Add Columns Automatically How To Insert Row Under Header Automatically