title: How do I move the range of data filtered by a VBA macro?
body: <p>I am currently using this code to filter a range in column A (starting in cell 1 and going to cell 600). It will leave only values starting with a number.</p>
  
  <pre><code>Sub WildAutofilter()
      Dim data As Range, c As Collection
      Dim v As String, i As Long, ary
      Set data = Range("A1:A23")
      Set c = New Collection
  
      On Error Resume Next
          For i = 2 To 600
              v = Cells(i, 1).Value
              If Left(v, 1) = "1" Or Left(v, 1) = "2" Or Left(v, 1) = "3" Or Left(v, 1) = "4" Or Left(v, 1) = "5" Or Left(v, 1) = "6" Or Left(v, 1) = "7" Or Left(v, 1) = "8" Or Left(v, 1) = "9" Then
                  c.Add v, CStr(v)
              End If
          Next i
      On Error GoTo 0
  
      ReDim ary(3 To c.Count - 1)
      For i = 4 To c.Count
          ary(i - 1) = c.Item(i)
      Next i
  
      With ActiveSheet.Range("$A$1:$A$23")
          .AutoFilter Field:=1, Criteria1:=(ary), Operator:=xlFilterValues
      End With
  End Sub
  </code></pre>
  
  <p>This code works fine for this location but the data that I actually want to filter is in column C, Starting in cell 3. I have tried to alter the code to the following: </p>
  
  <pre><code>Sub WildAutofilter()
      Dim data As Range, c As Collection
      Dim v As String, i As Long, ary
      Set data = Range("C3:C26")
      Set c = New Collection
  
      On Error Resume Next
          For i = 4 To 600
              v = Cells(i, 3).Value
              If Left(v, 3) = "1" Or Left(v, 3) = "2" Or Left(v, 3) = "3" Or Left(v, 3) = "4" Or Left(v, 3) = "5" Or Left(v, 3) = "6" Or Left(v, 3) = "7" Or Left(v, 3) = "8" Or Left(v, 3) = "9" Then
                  c.Add v, CStr(v)
              End If
          Next i
      On Error GoTo 0
  
      ReDim ary(0 To c.Count - 1)
      For i = 1 To c.Count
          ary(i - 1) = c.Item(i)
      Next i
  
      With ActiveSheet.Range("$C$3:$C$26")
          .AutoFilter Field:=1, Criteria1:=(ary), Operator:=xlFilterValues
      End With
  End Sub
  </code></pre>
  
  <p>This always returns a subscript out of range error and highlights this line "ReDim ary(0 To c.Count - 1)". I am not very advanced at visual basic. Most of my experience is in 'Frankensteining' other peoples code to make it do what I want, which is exactly what I did with this code. I'm not sure if I am just not changing the right references but if someone could help me out with this, that would be much appreciated.  </p>