How to Debug User Defined Functions

  • Thread starter Thread starter Kieranz
  • Start date Start date
K

Kieranz

Hi All,
I have written a user defined function but when i go to VBE and press
F8 to step thru the code it does not work. I have gone on many
websites but most seem to show you how to create, not after... like
debug. Any help or website referral appreciated. Thks.
Rgds
KZ
 
Hi Kieranz,

To step through the function's code, try inserting break
points in the function code and then insert a new instance of
the function in the worksheet.
 
select the first line in the function and press F9 to set a breakpoint

Then go to the Excel screen and cause a calculation that calls the the UDF

Charles
______________________
Decision Models
FastExcel 2.3 now available
Name Manager 4.0 now available
www.DecisionModels.com
 
Hi Kieranz,

Just a little explain...:
you can debuging this directly by pressing F8 in this function:
Function FuncA()
FuncA = "AA"
Debug.Print FuncA
End Function

But not for this:
Function FuncB(Str As String) As String
FuncB = Str
Debug.Print FuncB
End Function

you have to use sub to call FuncB:
Sub TesFunction()
Call FuncB("BB")
End Sub
 
You cannot enter into "break-mode" for sub or function procedures that
require mandatory arguments. The trick is to set a break point in the
function and call the function from another macro.
Leo
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top