Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
No Name
 
Posts: n/a
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 102
Default 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   Report Post  
Posted to microsoft.public.excel.programming
No Name
 
Posts: n/a
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 102
Default 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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Help! having problems with macros/coding Derrick Excel Discussion (Misc queries) 0 July 31st 09 02:15 PM
problems with macros cjjoo Excel Worksheet Functions 3 September 8th 05 10:00 AM
Problems calling macros in addin from within macros Andibevan[_4_] Excel Programming 2 August 16th 05 09:29 AM
noob: problems with macros in invoice dogfeet Excel Programming 2 August 31st 04 01:10 AM
Macros Problems bee Excel Programming 2 December 31st 03 09:54 PM


All times are GMT +1. The time now is 08:55 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"