title: 400 Error Excel Macro
body: <p>I'm trying to run a macro that will delete rows that don't contain a particular value in column B.  Here's my code:</p>
  
  <pre><code>Sub deleteRows()
      Dim count As Integer
      count = Application.WorksheetFunction.CountA(Range("AF:AF"))
      Dim i As Integer
      i = 21
      Do While i &lt;= count
          If (Application.WorksheetFunction.IsNumber(Application.WorksheetFunction.Search("OSR Platform", Range("B" &amp; i))) = False) Then
              If (Application.WorksheetFunction.IsNumber(Application.WorksheetFunction.Search("IAM", Range("B" &amp; i))) = False) Then
                  Rows(i).EntireRow.Delete
                  i = i - 1
                  count = count - 1
              End If
          End If
          i = i + 1
      Loop
  End Sub
  </code></pre>
  
  <p>Now what it SHOULD be doing is the following:</p>
  
  <p>1.) Find the number of rows to go through and set that as count (this works)</p>
  
  <p>2.) Start at row 21 and look for "OSR Platform" and "IAM" in column B [this kind of works  (see below)]</p>
  
  <p>3.) If it finds neither, delete the entire row and adjust the count and row number as necessary (this works)</p>
  
  <p>For some reason, whenever the code gets to the first If statement, an error window with a red X pops up that just says "400."  As far as I can tell, I have written everything syntactically soundly, but clearly there's something wrong.</p>