title: compiler error: Expected: end of statement when using "To" statement for array range excel vba
body: <p>For a project I am working on I'm using a param array to grab string values from a user and then run an autofilter incorporating string values from the array. However, whenever I use a <code>To</code> statement(E.G. <code>Boundaries = LBound(ArrayHere) To UBound(ArrayHere)</code>) I get the following error:</p>
  
  <p><strong>Screenshot:</strong>
  <img src="https://i.stack.imgur.com/ai4nv.png" alt="Compiler Error when using &quot;To&quot; statement in variable."></p>
  
  <p><strong>Code:</strong>    </p>
  
  <pre><code>Sub FilterWorkbookByServiceCode(FileName As String, WorkSheetName As String, Start As String, EndColumn As String, Field As Integer, ParamArray Numbers() As Variant)
  
      Dim Boundaries As Long
  
      Boundaries = LBound(Numbers) To Ubound(Numbers) 'Line Compiler error occurs on.
  
      Workbooks(FileName).Worksheets(WorkSheetName).Activate
      Range(Start).End(xlDown).Select
      Range(EndColumn &amp; ActiveCell.Row).Select
  
  
      With Range(Start &amp; ":" &amp; ActiveCell.Address)
          .Select
          .AutoFilter Field:=Field, Criteria1:=Numbers(), Operator:=xlFilterValues
      End With
  End Sub
  </code></pre>
  
  <p>I'm stumped on what I should do to correct this issue so any help is appreciated.</p>
  
  <p><strong>Edit:</strong></p>
  
  <p>To be a bit more clear, I'm trying to get the range of the param array, and then store it in a variable. I need to find the range of the array dyanmically as the user can input varying amount of values into the array, and then call each value from the array to use as the criteria for the autofilter.</p>