View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.misc
joel joel is offline
external usenet poster
 
Posts: 9,101
Default How to use debugger

You can set break points and step through the code. You can add a watch to
variables.


Set Break Point - click on line and press F9
step through code - Press F8
See value of variables
Hover over the variable or add watch by highlighting a variable and
right click. then select Add Watch


It is easy todebug code by using intermediate variables.

instead of

function Myfunction(V1 as Integer,V2 as Integer,V3 as Integer)

Myfunction = V1 + V2 / V3

end function


Use

function Myfunction(V1 as Integer,V2 as Integer,V3 as Integer)

Myfunction = V1 + V2
Myfunction = Myfunction/ v3

end function


Note the two functions give differnt results since multiplication is
performed before addition

Should be

function Myfunction(V1 as Integer,V2 as Integer,V3 as Integer)

Myfunction = V2/V3
Myfunction = V1 + V3

end function



"NDBC" wrote:

I have got my code for a user form working now. It has no technical code
errors but I think one of the conditions in an if statement may be selecting
incorrect cells. How can I check the values of different variables whilst it
is running. I realise I could set up the code so it puts variables in set
cells for checking but is there an easier way.

I noticed when it took me to debugger when i was getting code errors before
if i held my mouse over the variable names it would give me the current
value. This is what I would like to be able to get. Can I get this without
deliberately putting in code errors.