title: VBA - invalid qualifier when getting array length
body: <p>I am trying to make a function that puts the param into an array, then returns a random index value of the array. My code gets a <code>compile error: invalid qualifier</code> at <code>arr.Length</code>. So far I have:</p>
  
  <pre><code>Function myFunction(List As Range)
      Dim arr()
      Dim indx
  
      arr = List
      indx = (Int(Rnd()) * arr.Length)   'error here
  
      myFunction = indx
  End Function
  </code></pre>
  
  <p>Not sure if I am using the array right, or returning the value right - Please help</p>
  
  <p><strong>REVISION 1</strong></p>
  
  <p>Replaced .length with ubound and lbound - now I am getting a <code>#VALUE</code> error in the cell when it should be returning the array's index value.</p>
  
  <pre><code>Function myFunction(List as Range)
  
      Dim arr()
      Dim indx as Integer
  
      arr = List
      indx = Int(Rnd() * (UBound(arr) - LBound(arr) + 1)) 'indx
  
      myFunction = arr(indx)
  End Function
  </code></pre>