title: Excel VBA - Using Ranges as Optional parameters for functions?
body: <p>I'd like to write a VBA function that has a Range as an optional parameter. For instance something like:</p>
  
  <pre><code>Public Function testfunc(S As String, Optional R As Range) As String
  testfunc = S
  For Each cell In R
  testfunc = testfunc + cell
  Next cell
  End Function
  </code></pre>
  
  <p>I tried the function above, but I get a #VALUE! error. I also tried wrapping the For loop inside an If (R) Then...End If statement.</p>
  
  <p>What would be the way to deal with an optional Range, where if the range exists, then it is iterated through via a For Each loop?</p>