title: Delete row in Google Sheets if certain "word" is found in cell
body: <p>I have a Google Sheet with over 3000 rows. Some of the rows contain words that are not relevant..So I need a way to delete these in bulk. For example, cells will contain something like:</p>
  
  <pre><code> # | Product
  -------------------------------
   1 | Cool new product
   2 | Old product
   3 | Product that's old
  </code></pre>
  
  <p>I want to delete all of the rows that contain the word "old".</p>
  
  <p>I found a script that's doing half the job, but it requires the "word" to match the entire cell, not just some of the cell.</p>
  
  <p>Line 17 in the code below is what needs to be adjusted:</p>
  
  <hr>
  
  <pre><code>16 |
  17 |      if (row[1] == 'old')
  18 |
  </code></pre>
  
  <hr>
  
  <p><strong>Here's the code:</strong></p>
  
  <pre><code>/**
   * Deletes rows in the active spreadsheet that contain 'word' in column B
   * For more information on using the Spreadsheet API, see
   * https://developers.google.com/apps-script/service_spreadsheet
   */
  
  function readRows() {
   var sheet = SpreadsheetApp.getActiveSheet();
   var rows = sheet.getDataRange();
   var numRows = rows.getNumRows();
   var values = rows.getValues();
  
   var rowsDeleted = 0;
   for (var i = 0; i &lt;= numRows - 1; i++) {
   var row = values[i];
   if (row[1] == 'old') {
   sheet.deleteRow((parseInt(i)+1) - rowsDeleted);
   rowsDeleted++;
   }
   }
  };
  
  
  /**
   * Adds a custom menu to the active spreadsheet, containing a single menu item
   * for invoking the readRows() function specified above.
   * The onOpen() function, when defined, is automatically invoked whenever the
   * spreadsheet is opened.
   * For more information on using the Spreadsheet API, see
   * https://developers.google.com/apps-script/service_spreadsheet
   */
  function onOpen() {
   var sheet = SpreadsheetApp.getActiveSpreadsheet();
   var entries = [{
   name : "Remove rows where column B is 'old'",
   functionName : "readRows"
   }];
   sheet.addMenu("Remove Rows", entries);
  };
  </code></pre>
  
  <p><br>
  <br>
  <br>
  It adds a menu at the top right..Looks like this,
  <br>
  <br></p>
  
  <p><a href="https://i.stack.imgur.com/nf02O.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/nf02O.png" alt="Remove Rows"></a></p>