title: filter for and delete rows in excel using powershell
body: <p>I am still very new to powershell and feel like this might be a simple question, but I am stuck on my program trying to filter my excel spreadsheet, and then delete the filtered rows. </p>
  
  <p>ideally I would like to filter for all the rows that do NOT say "NO DATA" in column A starting at Row 3. 
  once I have all of those rows I would like to delete them all. 
  Then bring back all the rows that have "NO DATA"</p>
  
  <p>what I cant figure out is how to write the script so that the filter starts at row 2, and how to filter for all the rows that do NOT say "NO DATA" </p>
  
  <pre><code>$worksheet.usedrange.autofilter(1, -ne "NO DATA", 3)
  $worksheet.usedrange.offset(1,0).specialcells(12).Entirerow.Delete() 
  $worksheet.ShowAllData()
  </code></pre>
  
  <p>when I try what seems logical to me I get 2 errors, one is "missing expression" after the',' before -ne, and the other is "unable to get the Auto filter property of the range class" referring to the (Column#, Text, Row#) portion. </p>
  
  <pre><code>$worksheet.usedrange.autofilter(1, "NO DATA", 2)
  $worksheet.usedrange.offset(1,0).specialcells(12).Entirerow.Delete() 
  $worksheet.ShowAllData()
  </code></pre>
  
  <p>This code works but gives me the wrong data set (I'm left with everything I wanted deleted, and it still filters from row 1 and not row 2. </p>
  
  <p>any help would be great. </p>