Cannot step through entire macro - works to a point then runs rest of commands

KGee

Well-known Member
Joined
Nov 26, 2008
Messages
530
Office Version
  1. 365
  2. 2016
Platform
  1. Windows
I'm getting a macro error in a file that hasn't been modified in nearly a year. I suspect it has something to do with the machine I'm using now which crashes Excel when I select yes to debug the code. So I am trying to manually step through the code using F8 to determine which line it doesn't like but I get to a certain point and then it tries to run the rest of the macro. Any reason why it would do something like this? In the meantime I'm going to put in a number of breakpoints to see if that helps me find the problem. Thanks
 

Excel Facts

Copy PDF to Excel
Select data in PDF. Paste to Microsoft Word. Copy from Word and paste to Excel.

jsb1921

Board Regular
Joined
Aug 14, 2020
Messages
70
Office Version
  1. 2007
Platform
  1. Windows
  2. Web
which ever line you think the error is, before that, insert a line
on error goto 0
and debug again. remove the line when you have found out the error.
 
Solution

KGee

Well-known Member
Joined
Nov 26, 2008
Messages
530
Office Version
  1. 365
  2. 2016
Platform
  1. Windows
Thanks jsb I was able to figure out which line of code is at fault. I am adding a new workbook and based on the link Peter provided it seems that might be one of the triggers for this step-through behavior. So the line causing the problem is doing an XLPasteFormats. I will open a separate thread for that issue but the strange thing is I have the exact same code in multiple files and it is only crashing in this file.
 

Peter_SSs

MrExcel MVP, Moderator
Joined
May 28, 2005
Messages
48,580
Office Version
  1. 365
Platform
  1. Windows
I am adding a new workbook and based on the link Peter provided it seems that might be one of the triggers for this step-through behavior.
That is exactly the sort of thing that used to be the problem for me stepping through the code. I made the registry change and haven't experienced the run-through behaviour ever again. 🎉
 

KGee

Well-known Member
Joined
Nov 26, 2008
Messages
530
Office Version
  1. 365
  2. 2016
Platform
  1. Windows
That is exactly the sort of thing that used to be the problem for me stepping through the code. I made the registry change and haven't experienced the run-through behaviour ever again. 🎉
The Reg is locked down on our machines but I already have a pending request to get admin rights so I'll be able to change it soon...hopefully. Thanks
 

Watch MrExcel Video

Forum statistics

Threads
1,130,240
Messages
5,641,038
Members
417,190
Latest member
Sdwd76

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