title: Calling a function using variable name in VBA
body: <p>Thanks in advance.</p>
  
  <p>I'm trying to call a function using a variable name. It's throwing the error </p>
  
  <p><strong>The macro 'testfunc' cannot be found.
  Resume without error</strong></p>
  
  <p><strong>My Code:</strong> I tried below 3 statements but all are throwing the same error.</p>
  
  <pre><code>sFuncName = "testfunc"
  
  ExtractData = Application.Run("Sheet.xls" &amp; sFuncName, s1, s2)
  
  ExtractData = Application.Run(sFuncName, s1, s2)
  
  ExtractData = CallByName("Sheet.xls", sFuncName, VbMethod, s1, s2)
  </code></pre>
  
  <p>Note that the <code>sFuncName</code> returns a value &amp; I have 2 Excels opened at that moment, I'm trying to copy data from one Excel to other.</p>
  
  <p>Please help me in achieving this.</p>
  
  <pre><code>Private Function ABC
    sFuncName = oMapWksht.Cells(sMapRowItr, 3).Value
    'sFuncName = "testfunc"
    ExtractData = Application.Run("Sheet.xls" &amp; sFuncName, s1, s2)
    'ExtractData = Application.Run(sFuncName, s1, s2)
    'ExtractData = CallByName("Sheet.xls", sFuncName, VbMethod, s1, s2)
  End Function
  Public Function testfunc(ByVal s1 As String, ByVal s2 As String) As    Boolean
  --
  ---
  ----
  End Function
  </code></pre>