Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Tracing problems with macros
Hi
Is there a trace function - for spotting where macros crash? I've been trying to get one functioning all day and it doesn't help much (when as green as I am) when all I get is an error! Cheers. Andy. |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Tracing problems with macros
you can use the debugging information as a way of tracing where an
error occurrs. Set a breakpoint at the start of your macro by leftclicking the Grey Margin to the left of the code line you want to stop at. Once the code runs to there, the line will turn yellow. From there you can press the "F8" button or select options from the Debug toolbar. Eventually your error will occur and you'll know where. Using the immediate window in tandem with this can be very handy. You can type in questions like..."?Range("A1")" When you hit the enter key, the value of A1 is displayed. Try the help files too, they are very handy. |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
Tracing problems with macros
Brillinat! Thanks! That makes life easier. Is there any way of seeing the
spreadsheet as the macro runs - apart from arranging the Windows? When it runs a For Next loop how do you know where it's up to? Cheers. Andy. "Mark" wrote in message ups.com... you can use the debugging information as a way of tracing where an error occurrs. Set a breakpoint at the start of your macro by leftclicking the Grey Margin to the left of the code line you want to stop at. Once the code runs to there, the line will turn yellow. From there you can press the "F8" button or select options from the Debug toolbar. Eventually your error will occur and you'll know where. Using the immediate window in tandem with this can be very handy. You can type in questions like..."?Range("A1")" When you hit the enter key, the value of A1 is displayed. Try the help files too, they are very handy. |
#4
Posted to microsoft.public.excel.programming
|
|||
|
|||
Tracing problems with macros
You have to switch the views as far as I know. Another option, would
be to insert a debug.print statement into your loop. for example the following will print the values of the first 10 cells in column A Sub test() Dim CurRng As Range Dim Cnt As Integer Application.ScreenUpdating = False For Cnt = 0 To 9 Set CurRng = Range("A1").Offset(Cnt, 0) Debug.Print "Range " & CurRng.Address & " = " & CurRng Next Cnt Application.ScreenUpdating = True End Sub I prefer this method as I often will turn off the screenupdating process to smooth out performance. |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Help! having problems with macros/coding | Excel Discussion (Misc queries) | |||
problems with macros | Excel Worksheet Functions | |||
Problems calling macros in addin from within macros | Excel Programming | |||
noob: problems with macros in invoice | Excel Programming | |||
Macros Problems | Excel Programming |