---
title: "Loop delete specific rows with counter"
author: "Phil Bainbridge"
date: 2020-01-27T10:40:00+00:00
modified: 2020-01-27T09:06:12+00:00
canonical_url: https://pulse.appsscript.info/p/2020/01/loop-delete-specific-rows-with-counter/
markdown_url: https://pulse.appsscript.info/p/2020/01/loop-delete-specific-rows-with-counter.md
categories:
  - "Sheets"
  - "Snippet"
tags:
  - "pbainbridge.co.uk"
featured_image: https://pulse.appsscript.info/files/2019/12/Delete2BRow2BLoop.png
description: "The following Google Apps Script has been created to help with a recent difficulty I was having with deleting rows containing a specific value, where the loop was losing the row position due to the..."
---

# Loop delete specific rows with counter

![Loop delete specific rows with counter](https://pulse.appsscript.info/files/2019/12/Delete2BRow2BLoop.png)

> [https://www.pbainbridge.co.uk/2019/02/loop-delete-specific-rows-with-counter.html](https://www.pbainbridge.co.uk/2019/02/loop-delete-specific-rows-with-counter.html)Example table with specific rows to delete
> [https://www.pbainbridge.co.uk/2019/02/loop-delete-specific-rows-with-counter.html](https://www.pbainbridge.co.uk/2019/02/loop-delete-specific-rows-with-counter.html)Table with row 3 now deleted and data shifted up
> The following Google Apps Script has been created to help with a recent difficulty I was having with deleting rows containing a specific value, where the loop was losing the row position due to the spreadsheet data all shifting up a row each time one was deleted. Some searching online suggested looping through a spreadsheet in reverse (from bottom up) to avoid the shift, but that seems more like a workaround than a direct solution …

Source: *[The Gift of Script: Loop delete specific rows with counter*](https://www.pbainbridge.co.uk/2019/02/loop-delete-specific-rows-with-counter.html)

---

*Published by [Phil Bainbridge](https://pulse.appsscript.info/p/author/phillipbainbridge/) on [Pulse](https://pulse.appsscript.info/). Original article: [https://pulse.appsscript.info/p/2020/01/loop-delete-specific-rows-with-counter/](https://pulse.appsscript.info/p/2020/01/loop-delete-specific-rows-with-counter/)*
