79% OFF online library of tutorials for mastering Google Sheets

One time purchase $149

This tutorial is not available for free users. Please purchase a subscription to view this tutorial.

Hey there stranger!

Please sign-up or sign-in to watch this tutorial.

2 Ways to Delete Lines Quickly (CAREFUL, it's a script!)

About this Tutorial

Write an apps script to delete lines easily.

Video Transcript

 Hey, today I'm gonna tell you two ways to delete Rose quickly in two sort of different ways for different purposes. You might have a CRM and you have sort of a status and you might want to delete me. Let's move that and you can see right away that it deletes. Okay? That's one way I will show you how to do that in a second.

But first, if you have like a bunch of rows that you need to delete, I'm like, Don't wanna do like a double click with this is like you have to click, then press delete me, and then it deletes. It's a script. And I'll show you how to get the script. I'll show you how to use the script, but you actually can copy and paste the script and I'll show you how to edit it.

What you can do is if you go to a row and you just do right, click delete row. And now if I'm on any other row and I do, let's do here. So you go Taft, I do command y. It will do that. This last thing I did again and I've made another video about this in particular, this redo it's command y. It's up here.

Edit. It does the la it doesn't just redo, like it's not just used for command Z and then command Y to redo what you just undid. It's also just do the thing you did last again, and it's really cool because it's super fast. I don't know if you can even see it. It, it, it is one keystroke, it's it's command y or I guess it's two keystrokes.

Super quick, and I've gotten a lot of things done this way that I was just like, oh, I need to go through this, look at through with my eye, go through delete. Like anything that maybe here I can do like save, save, save. And then I'm just gonna right click delete row, and then. Do that again and again. And that is really quick.

But if you have the time to copy and paste the script that I have for you edit it and use it, I will show you how this is done. So we just do that. Watch out because I'm gonna do

watch out cuz if I do a bunch, let's do, whoops. Let me try to,  this, and I'm gonna do a couple at a time. Is it gonna get the last second one? See, it's not getting it if I try to do a bunch. Okay. So just so you know there is a little bit of a issue with scripts where like, if you do it too fast, The script doesn't know what's going on, and it, and it skips it a little.

So just pointing out the challenge using the script. If you go too fast, it doesn't happen, but I can, I think, yeah, now I'm just doing command v I'm pasting over the delete me and I'm doing it slower. And so it's happening, but it is, I have to go a little bit slower.  and because this is a script, I mean, it, it happens.

And unfortunately if someone is using your your sheet and doesn't know that this. Happens. It is very disturbing to them. So again, I am, I am giving you the caveats before sharing with you how I do it. And, and you can do it too. So first we need to go up to tools, a script editor. I have it open already, so if you are doing this right now, it may take some time for you to open that.

So pause the video. It, I already had it open, so it's very quick. And so what this function does, it goes function on edit.  every single time the the sheet has an edit, it's going to run this script. That is an issue too. I was running a lot of scripts on edit and it literally slowed down the entire sheet for everyone, every single time they ever made an edit.

So understand that when you're doing this, it's going on function, on edit, and then every other function you want to happen on an edit needs to go into this one function. In this one. That is like a weird thing with Google Scripts. Like it's actually to prevent you from creating a ton. Like you have to physically go to only the one fun on edit function and edit that and make, and you can add a bunch of stuff.

Absolutely. I've done this before added a bunch of different things and a lot of if statements, just a huge caveat to let you know what's going on. Okay, so here's what's going on. We're first getting where, what sheet we're on, what is the active.  and then we're saying if, if the range were on or the sheet we're on is equal to the name of the sheet, so you can change this to whatever sheet you want it to be done on.

The script to run on this one is sheet one. If I name this, if I change it to Maine, I would have to come here and, and change this right now. Let me do this. It will. Work because the first thing is false. If this is the name of the sheet that we're on, it's not so it's not gonna do anything. But if I change this to main, oops, change this to main save, come back and now it works.

Okay, so first it needs to be on the right page. Then the column needs to be the third column. This is a number three. If it's four, it will not work because this is the third column. C column is a third 1, 2, 3, third column. Now it's set to, did I save it? No. Okay. I'm gonna save it to four. It will not work.

So I can, oh, none of these are working, so I need to change this back to. Whoops. Again, . Whoops. Again, save. And now if I copy and paste this, it will delete it. There it goes. Okay. Then the last thing, these are all ands. These are ions. So all of these have to happen. The value, the value in the column needs to be delete me.

So if we add things to this, if it's save, it's not deleting it, right? If it's save. It will delete it now. So now I can copy and paste this and now it's deleting that. Is it? Is it saved? Oh, maybe it's not. Ooh.

Ah, that's why. So it's case sensitive . So let's go back here. Let's try again.  it is deleting save. Oh, no. So we literally have to write here, delete me. Let's save that. Go back. And now anytime we write, delete me. It's saved. But you notice, once I change this script, it's only happening on, on edit. Whenever I edit the sheet, it's.

and it's not looking at any of the existing ones that say, delete me. So again, a huge caveat when you are using a script, it's gonna run that script and it's only gonna look at that change. It's only gonna look at that edit, right? So these aren't being edited. So even though there is an edit, it's not looking for all of the delete mes.

This is a super simple script that says if all of these are true, meaning it is on the main. Page named Main. It's on the third column and it says, delete me. The value is Delete me in the third column, then get the row and delete. So S Delete here, dot delete Rowe. It's taking this event and it's deleting the Rowe that it's on.

And that's it. That is literally all it's doing is it is only edit editing on an edit. It is deleting that row. Hopefully this script can help you too. You can also take this script and move it along to different pages and you can definitely, and I would highly def, I would highly recommend fo commenting it out if you are not actively using it.

If you only want to use it during particular times.  like days I would go in and manually edit it out just in case someone doesn't know that that works. And also, again, I've done this before where sometimes we're like, Hey, this sheet just needs to be faster today. So I take all the unedited and I just get rid of them for the day or disable that script for that day.

Again, you can just comment it out and I think you can comment the entire. If you wish. But go ahead, grab grab this code. You're more than welcome. I just got it from online as well. So you're more than welcome to take it here. You need to change this column number again. You have to make sure it's the right page.

It's the right column number and it's the the correct thing. You actually want the thing to be deleted and fully deleted from your page. Not. Not edited, deleted hopefully this is helpful and you can now, now you have two ways to delete rose.


Sheet Stories / Video Notes + ADDED: Email Notifications



Add Click Tracking To Your Google Sheets | Bitly in a Google Sheet



Getting Started Coding in Apps Script

Seek Errors When Coding Apps Script

Think Like a Programmer: Develop The Mindset of an Apps Script Coder

ChatGPT Clone in Google Sheets Part 2

ChatGPT Clone in Google Sheets Part 1

Quickstart Tutorial OpenAI API in Google Sheets

Embed a Number in a Website from a Google Sheet

Create Navigation Like A Book or Presentation

Bjarne Asks: Can I show the Last Time of the Last Edit in a sheet?


Embed a Headline in a Website from Google Sheets

Capture Emails from Website Form to a Google Sheet (Without Zapier)

Hold a Giveaway Raffle in a Google Sheet

Create a new Spreadsheet from just a Name in a Sheet.



Email Yourself a Cell from a Google Sheet, Every Day

OpenSea Data Inside Sheets


Shwitter | Twitter in a Google Sheet

Create an Email Campaign Stats Calculator


Dylan Asks: How to Automatically Delete Rows If Cell Contains Value

Highlight Row as You Move Your Cell Selection

Create a Timer with Apps Script

LinkTree in a Google Sheet


Password Protecting Data In a Google Sheet

Automatic Weekly Backup of Google Sheets

Create a CPM Custom Function (Create Better Calculators!)

Move Entire Row when a Cell is changed to "Yes" - The $75,000 Google Script


What Can You Automate in Google Sheets? Every single trigger available to Google Sheet users


Google Sheets Stories? No! But we'll add timestamped video notes to your google sheets.


Sync Two Tabs Without ImportRange()

Password Protecting Data In a Google Sheet Part 2 The Basics

Benoit Asks: How to Convert Case



Learn to Code in Google Sheets, For Programmers

Add a Checkbox to Turn on Dark Mode


Write Your First Script


Find Keywords in Any Column, And create a quick search dropdown to find them.


Basic CRM - Add a Powerful Script To Move Row Based on Status

How To Improve: 1,000 Business ideas: Business Idea Generator


Let's Make a Bookmarklet!


Troubleshooting Bitly in a Google Sheet Script


Unique Features - Design a Better Dashboard Part 2



How To Set Up Stripe Webhook to Google Sheets with Google Script


How to Edit a Macro


Sheet Stories / Video Notes + Clear 24 Hour Old Videos


Add A Timestamp to Task Lists (without Now Formula)


Make your Custom Functions Like Native Functions | Custom Function Autocomplete



Create a Changelog Between 2 Cells Custom Function | To learn Double For Loop



New Syntax for WhatChanged Formula in Google Script


How to Record Macros


2 Ways to Delete Lines Quickly (CAREFUL, it's a script!)


Deep Inside Dark Habits Google Script


How to Trigger Macros Daily


5 Ways to Create Coupon Codes | Create UUIDs

Create a Radio Button From Checkboxes Using Google Script