# Exceptions in deleting rows in a spreadsheet

**URL:** <https://community.glideapps.com/t/exceptions-in-deleting-rows-in-a-spreadsheet/37224>\
**Category:** Ask for Help\
**Created:** [January 15, 2022, 2:20pm UTC](https://community.glideapps.com/t/exceptions-in-deleting-rows-in-a-spreadsheet/37224 "2022-01-15T14:20:20Z")\
**Posts on this page:** 20\
**Page:** 2

<div class="post-metadata">

**Author:** ![Himaladin](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/himaladin/32/71023_2.png) [@Himaladin](https://community.glideapps.com/u/Himaladin)\
**Post date:** [January 16, 2022, 3:49am UTC](https://community.glideapps.com/t/exceptions-in-deleting-rows-in-a-spreadsheet/37224/21 "2022-01-16T03:49:07Z")

</div>

I forgot where I used Row ID. Maybe I need to trace back. But what’s weird is that it also happens in sheet duplication, where row ID shouldn’t do anything.

---

<div class="post-metadata">

**Author:** ![Himaladin](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/himaladin/32/71023_2.png) [@Himaladin](https://community.glideapps.com/u/Himaladin)\
**Post date:** [January 16, 2022, 3:51am UTC](https://community.glideapps.com/t/exceptions-in-deleting-rows-in-a-spreadsheet/37224/22 "2022-01-16T03:51:00Z")

</div>

> [@Uzo](#):
>
> … i use only vlookup… is harder

Need to try. good advice.

---

<div class="post-metadata">

**Author:** ![Himaladin](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/himaladin/32/71023_2.png) [@Himaladin](https://community.glideapps.com/u/Himaladin)\
**Post date:** [January 16, 2022, 3:53am UTC](https://community.glideapps.com/t/exceptions-in-deleting-rows-in-a-spreadsheet/37224/23 "2022-01-16T03:53:39Z")

</div>

The strange thing is that I also have the query formula in another sheet (attendance), but no problem. Removed simultaneously in one action too.

---

<div class="post-metadata">

**Author:** ![Himaladin](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/himaladin/32/71023_2.png) [@Himaladin](https://community.glideapps.com/u/Himaladin)\
**Post date:** [January 16, 2022, 3:58am UTC](https://community.glideapps.com/t/exceptions-in-deleting-rows-in-a-spreadsheet/37224/24 "2022-01-16T03:58:40Z")

</div>

> [@Uzo](#):
>
> the user-specific column is populated in Glide when there are no rows?

This is needed in fact because I am using a checklist with a custom action to fill ##DELETE.

---

<div class="post-metadata">

**Author:** ![Uzo](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/uzo/32/22639_2.png) [@Uzo](https://community.glideapps.com/u/Uzo)\
**Post date:** [January 16, 2022, 4:02am UTC](https://community.glideapps.com/t/exceptions-in-deleting-rows-in-a-spreadsheet/37224/25 "2022-01-16T04:02:24Z")

</div>

what do you mean??? and this adding extra rows is happening only when you run Darren’s code?

---

<div class="post-metadata">

**Author:** ![Himaladin](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/himaladin/32/71023_2.png) [@Himaladin](https://community.glideapps.com/u/Himaladin)\
**Post date:** [January 16, 2022, 4:05am UTC](https://community.glideapps.com/t/exceptions-in-deleting-rows-in-a-spreadsheet/37224/26 "2022-01-16T04:05:08Z")

</div>

> [@Himaladin](#):
>
> At first, before all this happened, I used the Uzo method. Seeing the emergence of blank lines (increasing 500 lines), I thought I could combine your script. At first it seems to work, but a new blank line appears again. I checked all my formulas and fixed them and still can’t stop adding newlines.

Right now. Initially, there may have been an array of formula leaks that led me to discover this oddity.  
I’ll try again from the beginning to see if query is the source of the problem.

---

<div class="post-metadata">

**Author:** ![Uzo](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/uzo/32/22639_2.png) [@Uzo](https://community.glideapps.com/u/Uzo)\
**Post date:** [January 16, 2022, 4:14am UTC](https://community.glideapps.com/t/exceptions-in-deleting-rows-in-a-spreadsheet/37224/27 "2022-01-16T04:14:03Z")

</div>

you wanna delete all empty rows, or just up to the last nonempty row?

---

<div class="post-metadata">

**Author:** ![Himaladin](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/himaladin/32/71023_2.png) [@Himaladin](https://community.glideapps.com/u/Himaladin)\
**Post date:** [January 16, 2022, 4:14am UTC](https://community.glideapps.com/t/exceptions-in-deleting-rows-in-a-spreadsheet/37224/28 "2022-01-16T04:14:18Z")

</div>

![Screen Shot 2022-01-16 at 11.10.23](https://us1.discourse-cdn.com/flex002/uploads/glideapps/original/3X/d/3/d306bcaf34df86b0a520d02d3cef0f3a353e4e20.png)

Hahaha, now 3 sheets in multiple rows with ##Delete.  
I need to rest first. 😰

---

<div class="post-metadata">

**Author:** ![Himaladin](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/himaladin/32/71023_2.png) [@Himaladin](https://community.glideapps.com/u/Himaladin)\
**Post date:** [January 16, 2022, 4:17am UTC](https://community.glideapps.com/t/exceptions-in-deleting-rows-in-a-spreadsheet/37224/29 "2022-01-16T04:17:12Z")

</div>

> [@Uzo](#):
>
> you wanna delete all empty rows, or just up to the last nonempty row?

I wanna delete all empty rows, one by one. Anywhere to start.

---

<div class="post-metadata">

**Author:** ![Uzo](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/uzo/32/22639_2.png) [@Uzo](https://community.glideapps.com/u/Uzo)\
**Post date:** [January 16, 2022, 4:17am UTC](https://community.glideapps.com/t/exceptions-in-deleting-rows-in-a-spreadsheet/37224/30 "2022-01-16T04:17:38Z")

</div>

```auto

```

//Remove All Empty Columns in the Entire Workbook  
function removeEmptyColumns() {  
var ss = SpreadsheetApp.getActive();  
var allsheets = ss.getSheets();  
for (var s in allsheets){  
var sheet=allsheets[s]  
var maxColumns = sheet.getMaxColumns();  
var lastColumn = sheet.getLastColumn();  
if (maxColumns-lastColumn != 0){  
sheet.deleteColumns(lastColumn+1, maxColumns-lastColumn);  
}  
}  
}

//Remove All Empty Rows in the Entire Workbook  
function removeEmptyRows() {  
var ss = SpreadsheetApp.getActive();  
var allsheets = ss.getSheets();  
for (var s in allsheets){  
var sheet=allsheets[s]  
var maxRows = sheet.getMaxRows();  
var lastRow = sheet.getLastRow();  
if (maxRows-lastRow != 0){  
sheet.deleteRows(lastRow+1, maxRows-lastRow);  
}  
}  
}

```auto

```

---

<div class="post-metadata">

**Author:** ![Himaladin](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/himaladin/32/71023_2.png) [@Himaladin](https://community.glideapps.com/u/Himaladin)\
**Post date:** [January 16, 2022, 4:21am UTC](https://community.glideapps.com/t/exceptions-in-deleting-rows-in-a-spreadsheet/37224/31 "2022-01-16T04:21:57Z")

</div>

Not for all workbooks, just three sheets (not including headers).  
This script will close my glide hehehe… 😅

---

<div class="post-metadata">

**Author:** ![Himaladin](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/himaladin/32/71023_2.png) [@Himaladin](https://community.glideapps.com/u/Himaladin)\
**Post date:** [January 16, 2022, 4:23am UTC](https://community.glideapps.com/t/exceptions-in-deleting-rows-in-a-spreadsheet/37224/32 "2022-01-16T04:23:21Z")

</div>

What is the trigger?

---

<div class="post-metadata">

**Author:** ![Uzo](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/uzo/32/22639_2.png) [@Uzo](https://community.glideapps.com/u/Uzo)\
**Post date:** [January 16, 2022, 4:25am UTC](https://community.glideapps.com/t/exceptions-in-deleting-rows-in-a-spreadsheet/37224/33 "2022-01-16T04:25:13Z")

</div>

no… lol glide does not operate on empty rows… if you delete all empty columns and rows…Glide will sync much faster!.. you can put any trigger you want…  
Darren’s code is kind of weird… so maybe this one will work good for you 😉

---

<div class="post-metadata">

**Author:** ![Himaladin](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/himaladin/32/71023_2.png) [@Himaladin](https://community.glideapps.com/u/Himaladin)\
**Post date:** [January 16, 2022, 4:34am UTC](https://community.glideapps.com/t/exceptions-in-deleting-rows-in-a-spreadsheet/37224/35 "2022-01-16T04:34:12Z")

</div>

In this part, I don’t use the script from Darren and a notification appears that I can’t sync from the spreadsheet. And it keeps adding rows.  
I need to explain that I use a checklist with a custom action to fill the column with the word ##DELETE at once. This is what happened.  
I also use your script for other sheets, it still works normally. Only in this case, there seems to be something weird.

---

<div class="post-metadata">

**Author:** ![Uzo](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/uzo/32/22639_2.png) [@Uzo](https://community.glideapps.com/u/Uzo)\
**Post date:** [January 16, 2022, 4:38am UTC](https://community.glideapps.com/t/exceptions-in-deleting-rows-in-a-spreadsheet/37224/36 "2022-01-16T04:38:34Z")

</div>

what actions fill more than one row? multiple check list?

---

<div class="post-metadata">

**Author:** ![Himaladin](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/himaladin/32/71023_2.png) [@Himaladin](https://community.glideapps.com/u/Himaladin)\
**Post date:** [January 16, 2022, 4:41am UTC](https://community.glideapps.com/t/exceptions-in-deleting-rows-in-a-spreadsheet/37224/37 "2022-01-16T04:41:00Z")

</div>

No, Inline checklist.

 ![Screen Shot 2022-01-16 at 11.39.35](https://us1.discourse-cdn.com/flex002/uploads/glideapps/original/3X/c/d/cddd780e066c73550138fd0a91dcbc13ea31d898.png)

All have 3 sheets to fill with ##DELETE VALUE

---

<div class="post-metadata">

**Author:** ![Uzo](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/uzo/32/22639_2.png) [@Uzo](https://community.glideapps.com/u/Uzo)\
**Post date:** [January 16, 2022, 4:42am UTC](https://community.glideapps.com/t/exceptions-in-deleting-rows-in-a-spreadsheet/37224/38 "2022-01-16T04:42:38Z")

</div>

but each sheet, just one ##DELETE VALUE in one row?.. you don’t use ##… more than ones in 1 row?

---

<div class="post-metadata">

**Author:** ![Himaladin](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/himaladin/32/71023_2.png) [@Himaladin](https://community.glideapps.com/u/Himaladin)\
**Post date:** [January 16, 2022, 4:44am UTC](https://community.glideapps.com/t/exceptions-in-deleting-rows-in-a-spreadsheet/37224/39 "2022-01-16T04:44:02Z")

</div>

Yes. Check one then fill in ##DELETE, and so on. Only one per row-column per sheet.

---

<div class="post-metadata">

**Author:** ![Uzo](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/uzo/32/22639_2.png) [@Uzo](https://community.glideapps.com/u/Uzo)\
**Post date:** [January 16, 2022, 4:46am UTC](https://community.glideapps.com/t/exceptions-in-deleting-rows-in-a-spreadsheet/37224/40 "2022-01-16T04:46:06Z")

</div>

and what exactly is happening when you do that?

---

<div class="post-metadata">

**Author:** ![Himaladin](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/himaladin/32/71023_2.png) [@Himaladin](https://community.glideapps.com/u/Himaladin)\
**Post date:** [January 16, 2022, 4:46am UTC](https://community.glideapps.com/t/exceptions-in-deleting-rows-in-a-spreadsheet/37224/41 "2022-01-16T04:46:32Z")

</div>

Multiplication empty rows

[Previous page](https://community.glideapps.com/t/exceptions-in-deleting-rows-in-a-spreadsheet/37224.md?page=1)

[Next page](https://community.glideapps.com/t/exceptions-in-deleting-rows-in-a-spreadsheet/37224.md?page=3)
