Michał
Michał

Reputation: 61

Loop that will look for and delete particular row in Google Sheets script

I want to make loop in google sheets scripts that will in a first place get position of every row where on column B is "N/A" error and then delete the whole row. I start with that code but it doesn't return me the row of "N/A" string.

  function DeleteShops() {

  var ss = SpreadsheetApp.getActiveSpreadsheet().getSheetByName("MainShops");

  for(i=4; i < 282; i++){

  var RowCheck = ss.getRange(i, 2).getValues();

    if (RowCheck ===  "#N/A") {

   var RowToDelete = ss.getRange(i, 2).getRow();
       break;  

    } 

    else {

      continue;

         }

  }

   Logger.log(RowToDelete);

}  

Upvotes: 3

Views: 68

Answers (1)

ziganotschka
ziganotschka

Reputation: 26836

You have a spare =

Just change your line

if (RowCheck === "#N/A") {

to

if (RowCheck == "#N/A") {

Upvotes: 1

Related Questions