Debugging answer / tip

lundbhaiz

Active Member
Joined
Feb 16, 2010
Messages
386
hi. is there any way to check which module or which macro is throwing error in a list of macros run together in a workbook ? i have around 30 macros which are called from inside one another and i get a small error and i want to find out which macro and which line is throwing that error. can you helps plz ? thanks you
 

Excel Facts

Spell Check in Excel
Press F7 to start spell check in Excel. Be careful, by default, Excel does not check Capitalized Werds (whoops)
use Key F8 from inside the main macro. It will run the macro step by step.

F8 runs step 1
F8 again runs step 2
F8 again runs step 3 and so on
 
Upvote 0
Are you getting an error message with a Debug option, or are you handling all errors?
 
Upvote 0
thanks for reply. i already know this and i dont want to do this because it take very very long time to go through all 30 macros and also because some macros are looping columns or rows and i have more than 500000 rows for many sheets so you imagine how much time i will have to hold that F8 key :D i want a short way if there is any which give me option to jump on that error directly without going through the start of macro.
 
Upvote 0
Are you getting an error message with a Debug option, or are you handling all errors?

yes i get error message but no debug option. just error message and this is the problem. if i get debug than i can jump directly on error line of code but no debug option. i just get error message related to some formatting and the problem more is this formatting i am doing in lot of modules so it get very hard to find where the error exactly is popping in macro code. i am handling only some errors. not all. thanks rorya for replying.
 
Upvote 0
you can place the cursor in the line before you most likely get the error and then under debug use "run to Cursor"
 
Upvote 0
If you know the correct sequence of all thirty code routines e.g. Sub1 --> Sub2 etc. then:
Keep the immediate window open [CTRL+G] and at the end of each code routine add a specific line:
Rich (BB code):
Debug.Print "End of Sub1 is successful"
Run the code. It will give you the routine which fails you and then use fredlo's technique of F8.
 
Upvote 0
If you know the correct sequence of all thirty code routines e.g. Sub1 --> Sub2 etc. then:
Keep the immediate window open [CTRL+G] and at the end of each code routine add a specific line:
Rich (BB code):
Debug.Print "End of Sub1 is successful"
Run the code. It will give you the routine which fails you and then use fredlo's technique of F8.

fantastic :D this going to help me lot. thanks you for wonderful tip man. this will not be a perfect answer to my question but it certainly help me decrease off the load of finding that error in my macros.
 
Upvote 0

Forum statistics

Threads
1,214,591
Messages
6,120,426
Members
448,961
Latest member
nzskater

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top