# Delete all Google Sheet rows except header

**URL:** <https://community.make.com/t/delete-all-google-sheet-rows-except-header/3618>\
**Category:** Questions\
**Created:** [August 17, 2022, 2:50pm UTC](https://community.make.com/t/delete-all-google-sheet-rows-except-header/3618 "2022-08-17T14:50:10Z")\
**Posts on this page:** 15\
**Page:** 1

<div class="post-metadata">

**Author:** ![Dmitri\_Martin](https://dub1.discourse-cdn.com/flex013/user_avatar/community.make.com/dmitri_martin/32/2495_2.png) [@Dmitri\_Martin](https://community.make.com/u/Dmitri_Martin)\
**Post date:** [August 17, 2022, 2:50pm UTC](https://community.make.com/t/delete-all-google-sheet-rows-except-header/3618/1 "2022-08-17T14:50:10Z")

</div>

Is there a way in ONE operation to delete all rows in a Google Sheet except the first header row?

---

<div class="post-metadata">

**Author:** ![OHA\_Daniel](https://avatars.discourse-cdn.com/v4/letter/o/7cd45c/32.png) [@OHA\_Daniel](https://community.make.com/u/OHA_Daniel)\
**Post date:** [August 17, 2022, 3:43pm UTC](https://community.make.com/t/delete-all-google-sheet-rows-except-header/3618/2 "2022-08-17T15:43:41Z")

</div>

I don’t think that is possible with the tools Make provides (correct me if I am wrong), but you can add a script to your sheet like this one:

```auto
function deleteAllButHeader(){
  const app = SpreadsheetApp.getActiveSpreadsheet();
  const sheet = app.getActiveSheet();
  sheet.getRange(2,1,sheet.getLastRow(), sheet.getLastColumn()).setValue("")

}

```

This delets everything except the first row (if you have more header rows just change the first argument of getRange() to the row number you want to start deleting)

---

<div class="post-metadata">

**Author:** ![Dmitri\_Martin](https://dub1.discourse-cdn.com/flex013/user_avatar/community.make.com/dmitri_martin/32/2495_2.png) [@Dmitri\_Martin](https://community.make.com/u/Dmitri_Martin)\
**Post date:** [August 17, 2022, 4:02pm UTC](https://community.make.com/t/delete-all-google-sheet-rows-except-header/3618/3 "2022-08-17T16:02:41Z")

</div>

Interesting, but how would Make cause the function to execute?

---

<div class="post-metadata">

**Author:** ![JimTheMondayMan](https://dub1.discourse-cdn.com/flex013/user_avatar/community.make.com/jimthemondayman/32/223_2.png) [@JimTheMondayMan](https://community.make.com/u/JimTheMondayMan)\
**Post date:** [August 17, 2022, 5:16pm UTC](https://community.make.com/t/delete-all-google-sheet-rows-except-header/3618/4 "2022-08-17T17:16:05Z")

</div>

@Dmitri_Martin

To clear a range, you can use the clear cell module:

 ![image](https://europe1.discourse-cdn.com/flex013/uploads/make/original/2X/8/8ccf3de1d227c277207222e87bd13440773d120d.png)

To DELETE multiple rows, you would need to use the API call module:

 ![image](https://europe1.discourse-cdn.com/flex013/uploads/make/original/2X/c/c94cc62f5b921d6f9f38f8981a58a845b5e8db3b.png)

Notes:  
Replace “AAAA…AAAA” in the URL with your spreadsheet ID  
In the body, replace “123456789” with your sheet ID  
Rows are indexed from 0. The reference below refers to rows 2 through 1000001  
“endRowIndex”: 1000000,  
“startRowIndex”: 1

* * *

Jim - [The Monday Man (YouTube Channel)](https://www.youtube.com/TheMondayMan?sub_confirmation=1)  
**[What is Make & How can it help you with monday?](https://themondayman.com/make/)**  
**[We Create Custom Solutions - Your Make or Ours](https://themondayman.com/custom/)**  
**[Schedule a 1-on-1 Tutorial Session (for monday, Make or Excel)](https://themondayman.com/tutorial/)**

---

<div class="post-metadata">

**Author:** ![R-SimplifiedWebhooks](https://dub1.discourse-cdn.com/flex013/user_avatar/community.make.com/r-simplifiedwebhooks/32/3914_2.png) [@R-SimplifiedWebhooks](https://community.make.com/u/R-SimplifiedWebhooks)\
**Post date:** [August 17, 2022, 5:45pm UTC](https://community.make.com/t/delete-all-google-sheet-rows-except-header/3618/5 "2022-08-17T17:45:29Z")

</div>

There is a Module called “Perform Function” or something similar 🙂

---

<div class="post-metadata">

**Author:** ![JimTheMondayMan](https://dub1.discourse-cdn.com/flex013/user_avatar/community.make.com/jimthemondayman/32/223_2.png) [@JimTheMondayMan](https://community.make.com/u/JimTheMondayMan)\
**Post date:** [August 17, 2022, 8:46pm UTC](https://community.make.com/t/delete-all-google-sheet-rows-except-header/3618/6 "2022-08-17T20:46:43Z")

</div>

@R-SimplifiedWebhooks

You are correct that there is a Google Sheets module called Perform a Function.

But it is basically provides webhook functionality to call a Make scenario from a Google Spreadsheet. It is not intended to call Sheet functions from Make.

* * *

Jim - [The Monday Man (YouTube Channel)](https://www.youtube.com/TheMondayMan?sub_confirmation=1)  
**[What is Make & How can it help you with monday?](https://themondayman.com/make/)**  
**[We Create Custom Solutions - Your Make or Ours](https://themondayman.com/custom/)**  
**[Schedule a 1-on-1 Tutorial Session (for monday, Make or Excel)](https://themondayman.com/tutorial/)**

---

<div class="post-metadata">

**Author:** ![Jouher](https://avatars.discourse-cdn.com/v4/letter/j/f6c823/32.png) [@Jouher](https://community.make.com/u/Jouher)\
**Post date:** [August 18, 2022, 3:44am UTC](https://community.make.com/t/delete-all-google-sheet-rows-except-header/3618/7 "2022-08-18T03:44:07Z")

</div>

For bulk update, append and clear, we have built a tool where we can save tons of operations.

 ![image](https://europe1.discourse-cdn.com/flex013/uploads/make/original/2X/9/97c8b7ff85cd378e1d9ae2b04a9df487983ae4c0.png)

---

<div class="post-metadata">

**Author:** ![OHA\_Daniel](https://avatars.discourse-cdn.com/v4/letter/o/7cd45c/32.png) [@OHA\_Daniel](https://community.make.com/u/OHA_Daniel)\
**Post date:** [August 18, 2022, 9:18am UTC](https://community.make.com/t/delete-all-google-sheet-rows-except-header/3618/8 "2022-08-18T09:18:51Z")

</div>

@JimTheMondayMan clear cell module works best for what Dimitri wants I think. It’s one operation. I never realized you can have a range in there. Maybe the wording should be looked at. It reads like it works only for one cell.

---

<div class="post-metadata">

**Author:** ![JimTheMondayMan](https://dub1.discourse-cdn.com/flex013/user_avatar/community.make.com/jimthemondayman/32/223_2.png) [@JimTheMondayMan](https://community.make.com/u/JimTheMondayMan)\
**Post date:** [August 18, 2022, 12:26pm UTC](https://community.make.com/t/delete-all-google-sheet-rows-except-header/3618/9 "2022-08-18T12:26:22Z")

</div>

@OHA_Daniel

You might be right. But he did write DELETE. And, depending on the details, the actual delete is also only one operation.

* * *

Jim - [The Monday Man (YouTube Channel)](https://www.youtube.com/TheMondayMan?sub_confirmation=1)  
**[What is Make & How can it help you with monday?](https://themondayman.com/make/)**  
**[We Create Custom Solutions - Your Make or Ours](https://themondayman.com/custom/)**  
**[Schedule a 1-on-1 Tutorial Session (for monday, Make or Excel)](https://themondayman.com/tutorial/)**

---

<div class="post-metadata">

**Author:** ![JugaadiTech](https://dub1.discourse-cdn.com/flex013/user_avatar/community.make.com/jugaaditech/32/1254_2.png) [@JugaadiTech](https://community.make.com/u/JugaadiTech)\
**Post date:** [August 18, 2022, 11:52pm UTC](https://community.make.com/t/delete-all-google-sheet-rows-except-header/3618/10 "2022-08-18T23:52:27Z")

</div>

> [@OHA\_Daniel](#):
>
> Maybe the wording should be looked at. It reads like it works only for one cell.

> [@JimTheMondayMan](#):
>
> To clear a range, you can use the clear cell module:

![clear a cell](https://europe1.discourse-cdn.com/flex013/uploads/make/original/2X/7/7af02d7182358f9e20f257953d80b11e84c10902.gif)

> # :question: Lol how did i miss this?
> 
> you actually just **blew my mind** @JimTheMondayMan  
> gonna be a big change in how I build sheets scenarios.

> # 🧠 I know how though,
> 
> i just **got in the habit** of not having it, and **never actually** went back to check or verify.  
> neat to know

* * *

> **Submitting This to Support(clickme)**
>
> +^^this convo
> 
> ![image](https://europe1.discourse-cdn.com/flex013/uploads/make/original/2X/f/fef23b12553c46ce08f6de5ccaadb31c043d6b84.png)  
> I adapted years ago to clear a range not being an option… thus had no need to go back and check later. would have completely changed my make trajectory.
> 
> Hopefully they change the language for future makers.

---

<div class="post-metadata">

**Author:** ![JimTheMondayMan](https://dub1.discourse-cdn.com/flex013/user_avatar/community.make.com/jimthemondayman/32/223_2.png) [@JimTheMondayMan](https://community.make.com/u/JimTheMondayMan)\
**Post date:** [August 19, 2022, 11:00am UTC](https://community.make.com/t/delete-all-google-sheet-rows-except-header/3618/11 "2022-08-19T11:00:58Z")

</div>

@JugaadiTech

The module wording certainly implies single cell only. I don’t remember what made me test it. I was probably trying to figure out how to just make the call to the API directly. But there you go.

* * *

Jim - [The Monday Man (YouTube Channel)](https://www.youtube.com/TheMondayMan?sub_confirmation=1)  
**[What is Make & How can it help you with monday?](https://themondayman.com/make/)**  
**[We Create Custom Solutions - Your Make or Ours](https://themondayman.com/custom/)**  
**[Schedule a 1-on-1 Tutorial Session (for monday, Make or Excel)](https://themondayman.com/tutorial/)**

---

<div class="post-metadata">

**Author:** ![Dmitri\_Martin](https://dub1.discourse-cdn.com/flex013/user_avatar/community.make.com/dmitri_martin/32/2495_2.png) [@Dmitri\_Martin](https://community.make.com/u/Dmitri_Martin)\
**Post date:** [August 19, 2022, 3:00pm UTC](https://community.make.com/t/delete-all-google-sheet-rows-except-header/3618/13 "2022-08-19T15:00:56Z")

</div>

While the Clear a Cell module does allow clearing of a range, it still costs the same number of operations:

 ![1](https://europe1.discourse-cdn.com/flex013/uploads/make/original/2X/4/471e4a2b9ba93359ba4d2006a21e6355c817c565.jpeg)

![2](https://europe1.discourse-cdn.com/flex013/uploads/make/original/2X/f/f46d918fb316ded630d27b8cc2d73a3218061f54.jpeg)

The same hold true for the API approach:

 ![3](https://europe1.discourse-cdn.com/flex013/uploads/make/original/2X/d/db1ffb2534bbf8a3315bebab4270aa38f95d742e.jpeg)

I’m not sure how to implement the function approach, can a function be called by an API? Would doing so hide the number of rows deleted from Make so it wouldn’t count them as operations?

---

<div class="post-metadata">

**Author:** ![JimTheMondayMan](https://dub1.discourse-cdn.com/flex013/user_avatar/community.make.com/jimthemondayman/32/223_2.png) [@JimTheMondayMan](https://community.make.com/u/JimTheMondayMan)\
**Post date:** [August 19, 2022, 4:45pm UTC](https://community.make.com/t/delete-all-google-sheet-rows-except-header/3618/14 "2022-08-19T16:45:06Z")

</div>

@Dmitri_Martin

The problem there is not the method. This issue is the Search Rows module is returning 29 bundles. So, everything after that will execute 29 times.

If I am correctly understanding your objective, it is not needed at all. The range specified in the Cell parameter does not need to be exact. If you never have more than say 1,000,000 rows, and you want to clear through the last row, “A2:K1000000” will work just fine.

* * *

Jim - [The Monday Man (YouTube Channel)](https://www.youtube.com/TheMondayMan?sub_confirmation=1)  
**[What is Make & How can it help you with monday?](https://themondayman.com/make/)**  
**[We Create Custom Solutions - Your Make or Ours](https://themondayman.com/custom/)**  
**[Schedule a 1-on-1 Tutorial Session (for monday, Make or Excel)](https://themondayman.com/tutorial/)**

---

<div class="post-metadata">

**Author:** ![Dmitri\_Martin](https://dub1.discourse-cdn.com/flex013/user_avatar/community.make.com/dmitri_martin/32/2495_2.png) [@Dmitri\_Martin](https://community.make.com/u/Dmitri_Martin)\
**Post date:** [August 19, 2022, 5:45pm UTC](https://community.make.com/t/delete-all-google-sheet-rows-except-header/3618/15 "2022-08-19T17:45:29Z")

</div>

Of course! Sorry I missed that. You’ve solved the issue!

---

<div class="post-metadata">

**Author:** ![Make\_Bot](https://dub1.discourse-cdn.com/flex013/user_avatar/community.make.com/make_bot/32/14661_2.png) [@Make\_Bot](https://community.make.com/u/Make_Bot)\
**Post date:** [September 22, 2023, 2:06pm UTC](https://community.make.com/t/delete-all-google-sheet-rows-except-header/3618/17 "2023-09-22T14:06:32Z")

</div>


