PDA

View Full Version : Problem with UDF



nameuser321
04-04-2012, 09:37 AM
I have a bunch of UDFs in my spreadsheet. When I'm debuging my code they recalculate a bunch of times. Is there a way to prevent my editor from stepping through that part of the code?

p45cal
04-04-2012, 10:45 AM
tA couple of things I do; if the calculations aren't important to the debugging of the current vba development and the functions end up being called a lot, I change the name of those funcions by adding a 'x' or two.
You could try setting calculation to manual.
If it is vital the udf code is executed then when you find yourself stepped into such a function, Ctrl+Shift+F8 gets you back to your debugging code.
You can also step through you code in jumps by putting the cursor on where you want the code next to stop and pressing Ctrl+F8 (or putting a break point there, or even a Stop instruction in he code)

Bob Phillips
04-04-2012, 12:00 PM
When debugging, rather than Step Into (F8), Step Over (Shift-F8).

nameuser321
04-04-2012, 12:15 PM
Thank you for the assistance. The ctrl+f8 and ctrl+shft+f8 is something that I did not know about. I currently just write a stop instruction like you suggest. So I take it that there is no way to ignore stepping through certain pieces of code that you write, like an excel function? Like a tag that tells the editor to just ignore stepping through a certain piece of code?

nameuser321
04-04-2012, 12:18 PM
Password protecting a module would have been my guess, but i don't know how to protect just one module.

Bob Phillips
04-04-2012, 03:21 PM
Shift-F8 steps over it as I said, It still gets executed, you just don't step through it.

mikerickson
04-04-2012, 07:46 PM
When debugging, I find the RunToCursor option useful for running subroutines without stepping through each line.

Bob Phillips
04-05-2012, 12:15 AM
Debug.Assert is also very useful, I use it all the time, because it is conditional.

nameuser321
04-09-2012, 03:01 PM
Hey, I found an interesting way to solve this problem.


Application.enableevents = false

application.enableevents = true