title: How to pass range to Excel formula from VBA function
body: <p>I'm writing a <a href="/questions/tagged/vba" class="post-tag" title="show questions tagged 'vba'" rel="tag">vba</a> function to generate moving averages for smoothing a graph.  I need to use quartile ranges to adjust the smoothing formula.  How do I pass the QuartileRange to the <code>Evaluate</code> function to return the quartile value of that range so I may use it in my function?</p>
  
  <p>The function is called as follows</p>
  
  <pre><code>=MovingAverageSmoothQuartile( A1, 4, B1:b10 )
  </code></pre>
  
  <p>Where</p>
  
  <ul>
  <li><code>A1</code> is the value to smooth,</li>
  <li><code>4</code> is the number of values to use and</li>
  <li><p><code>B1:B10</code> is a column of samples used to calculate the quartile value.</p>
  
  <pre><code>Function MovingAverageSmoothQuartile(r As Range, ByVal m As Integer, QuartileRange As Range)
  ' returns a smoothed average using the 'rectangular' method
  Dim q1 As Double, q2 As Double, q3 As Double        
  q1 = Evaluate("Quartile( " + QuartileRange.Text + ", 1") ' &lt;--- Stuck here
  </code></pre></li>
  </ul>