title: Finding out which function called other funciton in VBA excel
body: <p>Problem
  I have an excel file with a quite complicated VBA code behind and I am having some problems to track back and debug the errors.
  Sometimes a function B gets a value that it should not get and crashes, but at this point it is not possible for me to know which other funciton called that function B, and the anylys process to finding it out is very much time consuming.</p>
  
  <p>My solution
  The solution could be transform all the functions I have in the following way:</p>
  
  <pre><code>Sub foo1(variable1 as string)
      'do whatever
  End Sub
  </code></pre>
  
  <p>into</p>
  
  <pre><code>Sub foo1(variable1 as string, inforvariable as string)
      'do whatever
  End Sub
  </code></pre>
  
  <p>Infovariable being the name of the function calling.
  This is obviously very time consuming (refactoring everything). Besides I dont know neither how to access the name of the "sub" of funcion of the code calling, something like:</p>
  
  <pre><code>infovariable = self.name
  call foo1(variable1, inforvariable)
  </code></pre>
  
  <p>Does not seems to exists in VBA</p>
  
  <p>Some ideas?</p>
  
  <p>I have a look <a href="https://stackoverflow.com/questions/19845944/dynamic-function-calls-in-excel-vba">here</a>, <a href="https://stackoverflow.com/questions/47134785/vba-function-call-from-excel">here</a>, and here</p>