Log to monitor the function in excel

mmb.nbn

New Member
Joined
Jul 20, 2009
Messages
23
How to put log statements at the beginning of every function with time stamp and at the exit time of the function in Excel. When the run is done with profiling flag enabled you view the log and understand how the function calls took place and in which order along with timelines.Some thing in regular languages like Java & C# following way.Can any one provide me code in Excel

Code:
Func1(int indent)
            If (Profile)
Log(time, indent, “Func1”);
            Do the function work;
            Call Func2(indent+1);
            If (Profile)
Log(time, indent, “Func1”);
 

Excel Facts

Wildcard in VLOOKUP
Use =VLOOKUP("Apple*" to find apple, Apple, or applesauce
It would be something like this. You can't use Log or Time (they're built-in functions) so I changed the names.

Code:
Public Function Func1(indent As Long)
  If (Profile = True) Then
    DoLog myTime, indent, "Func1"
  End If
  
  ' do the function work
  
  Call Func2(indent + 1)
  
  If (Profile = True) Then
    DoLog myTime, indent, "Func1"
  End If
End Function

The public/private declaration depends on your scoping. Also, if you're not returning a value, you don't need to make it a Function, rather you use Sub.
 
Last edited:
Upvote 0

Forum statistics

Threads
1,215,906
Messages
6,127,659
Members
449,395
Latest member
Perdi

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top