Using multiple criteria in Excel VBA Autofilter?
<p>I am basically trying to do this:</p>

<ol>
<li>If the top row has no filter, apply autofilter</li>
<li>If there is already some filter applied with some criteria, clear/reset the filter.</li>
<li>Now filter for all rows where column C matches someVarX and column F matches someVarY.</li>
</ol>

<p>I wasn't sure how to do 1. but for 2. I did </p>

<p><code>If Sheets(sheetName).FilterMode Then Sheets(sheetName).ShowAllData</code></p>

<p>For 3. I was unable to do more than one criteria. I tried</p>

<pre><code>Worksheets(sheetName).Range("A1").AutoFilter _
                    field:=3, _
                    Criteria1:=someVarX, _
                    VisibleDropDown:=False

Worksheets(sheetName).Range("A1").AutoFilter _
                    field:=6, _
                    Criteria1:=someVarY, _
                    VisibleDropDown:=False
</code></pre>

<p>How do I fix all this so it's using correct syntax?</p>