title: How can I use the VBA ''if'' function for triggering a filter when a specific text is in a column?
body: <p>I want to create an Excel Macro using Finance data out of our ERP system. The only problem is that the not all options in the &quot;status&quot; column are there every time I dump the data. The ''status'' column consists of things like: 'approved', 'rejected', 'awaiting approval', etc. I have the following code and want to first ask Excel to check whether or not 'rejected' is in the column before filtering (then I have different code triggering giving those cells a colour). Because 'rejected' isn't always a status, the code stops and the macro doesn't finish.</p>
  <pre><code> ActiveSheet.Range(&quot;$A$1:$K$128&quot;).AutoFilter Field:=10, Criteria1:= _
          &quot;Rejected&quot;
      Range(&quot;H125&quot;).Select
      Range(Selection, Selection.End(xlDown)).Select
      ...(more code)
  </code></pre>
  <p>How can I let the filter only trigger when ''rejected'' is present in that column (column K)?</p>