title: VBA variant array redim/resize inside function
body: <p>I want to pass a Nx1 array into a function, and get back a Mx1 array (i.e. just truncate the array down to size M). I have a strong preference for doing this as efficiently as possible.</p>
  
  <p>This doesn't seem to work:</p>
  
  <pre><code>Public Function cutarray(A As Variant, M As Integer)
      ReDim Preserve A(1 To M)
      cutarray = A
  End Function
  </code></pre>
  
  <p>This seems like it should be obvious, I'm just missing something.</p>
  
  <p>Also I should mention I'm calling this function directly from excel, e.g. <code>=cutarray(A1:A5000,75)</code></p>