title: Excel VBA: Call Sub procedure after executing a function
body: <p>In myFunction, I want to create a log in a sheet with the arguments of the function and the time it was last executed.</p>
  
  <p>My code is like this:</p>
  
  <pre><code>Function myFunction(arg1, arg2 As String)
  
     //code here
  
     Sheets("Sheet1").Range("A1") = arg1
     Sheets("Sheet1").Range("B1") = arg2
     Sheets("Sheet1").Range("C1") = datetime.Now
  
  End Function
  </code></pre>
  
  <p>This function doesn't work with the last 3 lines (it does otherwise). </p>
  
  <p>I also tried to create a separate module for this task:</p>
  
  <pre><code>Function myFunction(arg1, arg2 As String)
  
         //code here
  
      Call myLog(arg1,arg2)
  
      End Function
  </code></pre>
  
  <p>But it doesn't work either</p>
  
  <pre><code>Public Sub myLog(arg1,arg2)
     Sheets("Sheet1").Range("A1") = arg1
     Sheets("Sheet1").Range("B1") = arg2
     Sheets("Sheet1").Range("C1") = datetime.Now
  End Sub
  </code></pre>
  
  <p>Thanks in advance for helping!</p>