title: How to use index function in VBA to a dynamic range
body: <p>I got a <code>n x m data array</code> and I'm trying to compute the average value of a subset of that array without using a loop. </p>
  
  <p>In excel, I can use for example:</p>
  
  <pre><code>x = AVERAGE(INDEX(A1:A100,20,1):INDEX(A1:A100,50,3))
  </code></pre>
  
  <p>But not sure how to convert this into VBA. The following will give me an error:</p>
  
  <pre><code>x = Worksheetfunction.Average(Worksheetfunction.Index(ArrayX,20,1):Worksheetfunction.Index(ArrayX,50,3))
  </code></pre>
  
  <p>I'm assuming I cannot just use <code>":"</code> in between the functions. How can I get around it? Appreciate the help!</p>