title: Filtering Column Based on Range VBA
body: <p>I am presently working with data from a mainframe, not <a href="https://stackoverflow.com/questions/11620118/finding-numerical-value-pairs-with-conditionals-and-nested-if-then-statements">unlike the data presented here</a>. In this case, all I have are strings akin to 100-AAA for my criteria and for my target data set. I have searched for a similar solution, but I have not found a direct filter by range question for VBA on SO.</p>
  
  <p>I am attempting to filter a large dataset based on a range of criteria. Originally, I started playing with collections in separate classes/subroutines, but then I compressed to the use of ranges within a single subroutine, as follows:</p>
  
  <pre><code>Sub FilterTest1()
  
  Dim RngOne As Range
  Dim LastCell As Long
  
  Sheets("Criteria").Activate
  Sheets("Criteria").Select
  Range("A1").Select
  
  LastCell = Application.WorksheetFunction.CountA(ActiveSheet.Range("A:A"))
  
  Set RngOne = ActiveSheet.Range("A2:A" &amp; LastCell)
  
  Sheets("Sheet 1").Activate
  Sheets("Sheet 1").Select
  
  With ActiveSheet
      If .FilterMode Then
      .ShowAllData
      End If
  End With
  
  Columns("A:A").Select
  Selection.AutoFilter
  ActiveSheet.Range("A:A").AutoFilter Field:=1, Criteria1:=RngOne, Operator:=xlOr
  
  End Sub
  </code></pre>
  
  <p>Unfortunately, my range of cells does not filter the data, even when using criteria such as <code>Operator:=xlOr</code> - it just displays the very last cell value used for the criteria. The VBA code does not fail - it just does not filter properly based on the range.</p>
  
  <p>I feel certain that there exists a simple solution, but I cannot quite see it.</p>