Skip to content
Advertisement

Deleting Data In Bulk – Google sheets

I found this piece of code and need to modify it so that if it doesn’t find a result it will return and keep running next lines of code

JavaScript

So if it doesn’t find “JOHN” it currently stops running and throws an error.

I would like it to move onto next piece of code if no result found.

appreciate any help, this is my first post

Advertisement

Answer

I believe your goal is as follows.

  • You want to continue to run the script even when the value of JOHN is not found.

In this case, how about the following modification?

Modified script:

JavaScript
  • In this modification, when the value of JOHN is not found, by if (ranges.length > 0) {}, the script of Sheets.Spreadsheets.batchUpdate is skipped. By this, you can continue to run the script.
User contributions licensed under: CC BY-SA
9 People found this is helpful
Advertisement