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
 

Some videos you may like

Excel Facts

Can a formula spear through sheets?
Use =SUM(January:December!E7) to sum E7 on all of the sheets from January through December

fredlo2008

Active Member
Joined
Jan 12, 2012
Messages
254
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
 

RoryA

MrExcel MVP, Moderator
Joined
May 2, 2008
Messages
36,133
Office Version
  1. 365
  2. 2019
  3. 2016
  4. 2010
Platform
  1. Windows
  2. MacOS
Are you getting an error message with a Debug option, or are you handling all errors?
 

lundbhaiz

Active Member
Joined
Feb 16, 2010
Messages
386
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.
 

lundbhaiz

Active Member
Joined
Feb 16, 2010
Messages
386

ADVERTISEMENT

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.
 

fredlo2008

Active Member
Joined
Jan 12, 2012
Messages
254
you can place the cursor in the line before you most likely get the error and then under debug use "run to Cursor"
 

lundbhaiz

Active Member
Joined
Feb 16, 2010
Messages
386

ADVERTISEMENT

you can place the cursor in the line before you most likely get the error and then under debug use "run to Cursor"
you mean to say to do this while i press f8 ?
 

taurean

Well-known Member
Joined
Jun 17, 2011
Messages
2,179
Office Version
  1. 365
  2. 2016
Platform
  1. Windows
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.
 

lundbhaiz

Active Member
Joined
Feb 16, 2010
Messages
386
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.
 

Watch MrExcel Video

Forum statistics

Threads
1,123,110
Messages
5,599,773
Members
414,336
Latest member
Nicolas2465

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
Top