title: Hiding Rows if Cell in a Column Contains Certain Text or Autofiltering a Single Field with 4 Criteria
body: <p>I have a sheet with columns A through M, containing a table including all rows and columns. If, in column E, a cell contains the string(s) "Drive", "Inactivity", or "Halt" then I want the row to be hidden. If, in column E, a cell does <em>not</em> contain the string "UF_", then I want it to be hidden.</p>
  
  <p>I have tried several things and have looked in many places. Here is some code that I have tried:</p>
  
  <p>Try 1 (takes wayyyy to long):</p>
  
  <pre><code>With ActiveSheet
  loopct = 2
  
  While loopct &lt; count1
      DoEvents
      Application.StatusBar = "Making Table " &amp; loopct
      txtrmv1 = "Drive"
      txtrmv2 = "Inactivity"
      txtrmv3 = "Halt"
      txtkp = "UF_"
  
      celltxt = .Range("E" &amp; loopct).Value
  
      If InStr(1, celltxt, txtrmv1, vbTextCompare) Then
          .Range("E" &amp; loopct).EntireRow.Hidden = True
      End If
      If InStr(1, celltxt, txtrmv2, vbTextCompare) Then
          .Range("E" &amp; loopct).EntireRow.Hidden = True
      End If
      If InStr(1, celltxt, txtrmv3, vbTextCompare) Then
          .Range("E" &amp; loopct).EntireRow.Hidden = True
      End If
      If InStr(1, celltxt, txtkp, vbTextCompare) Then
          .Range("E" &amp; loopct).EntireRow.Hidden = False
      Else
          .Range("E" &amp; loopct).EntireRow.Hidden = True
      End If
  
      loopct = loopct + 1
  Wend
  
  End With
  </code></pre>
  
  <p>Try 2 (runs but accomplishes nothing):</p>
  
  <pre><code>Private Sub HideDrive(ByVal count1 As Long)
      Dim ws As Worksheet
      Dim rng As Range, aCell As Range, bCell As Range
  
      Set ws = ActiveWorkbook.Sheets("Sheet1")
  
      With ws
          Set rng = .Range("E2:E" &amp; CStr(count1))
  
          Set aCell = rng.Find(What:="Drive", LookIn:=xlValues, _
                      LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, _
                      MatchCase:=True, SearchFormat:=False)
  
          If Not aCell Is Nothing Then
              Set bCell = aCell
              Do
                  aCell.EntireRow.Hidden = True
                  Set aCell = rng.FindNext(After:=aCell)
  
              Loop While aCell Is Nothing And aCell.Address &lt;&gt; bCell
          End If
      End With
  End Sub
  </code></pre>
  
  <p>Here is what I was using when I only had one criteria to check for (obviously my sitation has changed):</p>
  
  <pre><code>ActiveWorkbook.ActiveSheet.ListObjects(tblnm).Range.AutoFilter Field:=5, Criteria1:= "=*UF_*"
  </code></pre>
  
  <p>What can I do to accomplish what I want? I haven't been able to get autofilter to work with more than two criteria. Please let me know!</p>