title: A function within a function in vba?
body: <p>Here is a simplified version of a function I use in a cell (=xxDay(B7) for example) to retrieve a day from a closed workbook:</p>
  
  <pre><code>    Function xxDay(row)
  
          Dim fName, Path, strSheet, strRef, strRng As Variant
  
          xxDay = ""
          Path = "C:\MMS\"
          fName = "Book1.xlsm"
          strSheet = "Sheet1"
          strRng = Cells(row, 3).Address(, , xlR1C1)
          strRef = "'" &amp; Path &amp; "[" &amp; fName &amp; "]" &amp; strSheet &amp; "'!" &amp; strRng
  
          xxDay = ExecuteExcel4Macro(strRef)
  
      End Function
  </code></pre>
  
  <p>I get a #VALUE returned in the cell.  I run it as Sub and it will return the expected results.  Is it possible to have a function call another function within itself?</p>
  
  <pre><code>    Sub SubxxDay()
  
          Dim fName, Path, strSheet, strRef, strRng, xxDay, row As Variant
  
          row = 7
          xxDay = ""
          Path = "C:\MMS\"
          fName = "Book1.xlsm"
          strSheet = "Sheet1"
          strRng = Cells(row, 3).Address(, , xlR1C1)
          strRef = "'" &amp; Path &amp; "[" &amp; fName &amp; "]" &amp; strSheet &amp; "'!" &amp; strRng
  
          xxDay = ExecuteExcel4Macro(strRef)
  
          MsgBox xxDay
      End Sub
  </code></pre>
  
  <p>Much appreciate any response.</p>