ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   How To Use Debug (https://www.excelbanter.com/excel-programming/350784-how-use-debug.html)

Minitman[_4_]

How To Use Debug
 
Greetings,

I have a UserForm that is giving me fits. I need to follow the code
as executes and see where the variables are being changed.

But I don't know how to use Debug!

Can someone show me how? or point me in the right direction?

Any assistance would be appreciated.

As always, Thanks in Advance.

-Minitman

Bob Phillips[_6_]

How To Use Debug
 
Select a line early in the code and add a breakpoint - F9.

Then when the code stops at that line, step through one line at a time - F8.

You can then hover over variables to see the value, select an expression and
Shift-F9 to get it evaluated, print a variable to the immediate window
(?myVar), or add a variable or property to the watch window.

--
HTH

Bob Phillips

(remove nothere from email address if mailing direct)

"Minitman" wrote in message
...
Greetings,

I have a UserForm that is giving me fits. I need to follow the code
as executes and see where the variables are being changed.

But I don't know how to use Debug!

Can someone show me how? or point me in the right direction?

Any assistance would be appreciated.

As always, Thanks in Advance.

-Minitman




GB

How To Use Debug
 
Since you are talking about debugging a userform and not a module. My
suggestion would be to go into the code of the userform. Find a line in
which you would like to start tracing. Press the F9 key. This inserts a
stop point in your code.

Run whatever it is that causes your form to be displayed.. (Provided that it
is only displayed when opening the workbook. If so, then just go to the
ThisWorkbook code where Workbook_Open is. Select a row in that sub routine,
then press the F5 key. F5 runs the current sub routine/function.)

When the program gets to the line of code that has the stop point (Red line)
you can step through, over, out, etc your code. Review the key shortcuts
that are provided in the Debug drop down window. And perhaps refer to the
VBA help of the debug to understand 1) what each option does, and 2) learn
the shortcut keys to speed your debugging. You could also show the debug
toolbar, which may help in all of this also. :)

You also have two utility windows at your service, you have a watch window
and an immediate window. The watch window will show you the value(s) of
variables making it easy to trace. The immediate window can be used to show
the value of a variable if you want, but can be painful. :) To "print"
something preface it with a question mark: (i.e., ? activesheet.name) If you
want to assign/reassign a variable to test a limit you can just do that in
the immediate window when you have stopped at an appropriate location.

I.e., I=10

Hopefully this stuff will get you started.

"Minitman" wrote:

Greetings,

I have a UserForm that is giving me fits. I need to follow the code
as executes and see where the variables are being changed.

But I don't know how to use Debug!

Can someone show me how? or point me in the right direction?

Any assistance would be appreciated.

As always, Thanks in Advance.

-Minitman


Minitman[_4_]

How To Use Debug
 
Thanks Bob. That helps

On Wed, 18 Jan 2006 17:26:34 -0000, "Bob Phillips"
wrote:

Select a line early in the code and add a breakpoint - F9.

Then when the code stops at that line, step through one line at a time - F8.

You can then hover over variables to see the value, select an expression and
Shift-F9 to get it evaluated, print a variable to the immediate window
(?myVar), or add a variable or property to the watch window.



Minitman[_4_]

How To Use Debug
 
Even better, Thank you very much.

-Minitman

On Wed, 18 Jan 2006 09:33:02 -0800, "GB"
wrote:

Since you are talking about debugging a userform and not a module. My
suggestion would be to go into the code of the userform. Find a line in
which you would like to start tracing. Press the F9 key. This inserts a
stop point in your code.

Run whatever it is that causes your form to be displayed.. (Provided that it
is only displayed when opening the workbook. If so, then just go to the
ThisWorkbook code where Workbook_Open is. Select a row in that sub routine,
then press the F5 key. F5 runs the current sub routine/function.)

When the program gets to the line of code that has the stop point (Red line)
you can step through, over, out, etc your code. Review the key shortcuts
that are provided in the Debug drop down window. And perhaps refer to the
VBA help of the debug to understand 1) what each option does, and 2) learn
the shortcut keys to speed your debugging. You could also show the debug
toolbar, which may help in all of this also. :)

You also have two utility windows at your service, you have a watch window
and an immediate window. The watch window will show you the value(s) of
variables making it easy to trace. The immediate window can be used to show
the value of a variable if you want, but can be painful. :) To "print"
something preface it with a question mark: (i.e., ? activesheet.name) If you
want to assign/reassign a variable to test a limit you can just do that in
the immediate window when you have stopped at an appropriate location.

I.e., I=10

Hopefully this stuff will get you started.

"Minitman" wrote:

Greetings,

I have a UserForm that is giving me fits. I need to follow the code
as executes and see where the variables are being changed.

But I don't know how to use Debug!

Can someone show me how? or point me in the right direction?

Any assistance would be appreciated.

As always, Thanks in Advance.

-Minitman




All times are GMT +1. The time now is 07:47 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com