Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
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 |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
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 |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
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 |
#4
Posted to microsoft.public.excel.programming
|
|||
|
|||
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. |
#5
Posted to microsoft.public.excel.programming
|
|||
|
|||
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 |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
DeBug | Excel Discussion (Misc queries) | |||
help with debug | New Users to Excel | |||
debug | Excel Programming | |||
help with debug | Excel Programming | |||
debug help | Excel Programming |