title: Excel VSTO Autofilter not working right?
body: <p>I'm working on a Excel VSTO project with Office &amp; VS 2010. I have the code to get a range but I can't seem to get the Autofilter to work right. Heres the code I have so far:</p>
  
  <pre><code>Excel.Workbook wb = (Excel.Workbook)Globals.ThisWorkbook.InnerObject;
  Excel.Name rngN = wb.Names.Item("MyNamedRange", System.Type.Missing, System.Type.Missing);
  Excel.Range rng = rngN.RefersToRange;
  int allRows = rng.Rows.Count;
  rng.AutoFilter(8, "ST", Microsoft.Office.Interop.Excel.XlAutoFilterOperator.xlOr, System.Type.Missing, null);
  int filteredRows = rng.Rows.Count;
  </code></pre>
  
  <p>However, in this example, the row counts are identical and my range is not filtered at all - Im referring to the variables <strong>allRows</strong> and <strong>filteredRows</strong> above. So I'm either not implementing the filter correctly and or my filter statement is wrong. My filter line:</p>
  
  <pre><code>rng.AutoFilter(8, "ST", Microsoft.Office.Interop.Excel.XlAutoFilterOperator.xlOr, System.Type.Missing, null);
  </code></pre>
  
  <p>So my understanding is that this line would look for all matches of "ST" in the 8th field. Is that not correct? Why are my record counts the same?</p>