title: Can a VBA function in Excel return a range?
body: <p>I seem to be getting a type mismatch error when trying to do something like this:</p>
  
  <p>In new workbook:</p>
  
  <pre><code>A1 B1
  5  4
  
  Function Test1() As Integer
      Dim rg As Range
      Set rg = Test2()
      Test1 = rg.Cells(1, 1).Value
  End Function
  Function Test2() As Range
      Dim rg As Range
      Set rg = Range("A1:B1")
      Test2 = rg
  End Function
  </code></pre>
  
  <p>Adding =Test1() should return 5 but the code seems to terminate when returning a range from test2(). Is it possible to return a range?</p>