Macro stops at each line of code

Misca

Well-known Member
Joined
Aug 12, 2009
Messages
1,760
Office Version
  1. 365
Platform
  1. Windows
I'm using two computers (both Windows 7 / Office 2010) at the office. The only difference is the older one is about a year older than the new one (and is a bit slower as well I guess).

I've written a macro that turns different kinds of price lists into a data table. I've written it using my newer machine and the code runs like a dream every time I run it on that machine. But when I'm running it from the older machine the code "bugs" on every line of code: Even when it's something simple like writing a "USD" into a cell.

The error message says something general (can't remember what exactly but there was no error code or whatsoever: "Automation Error" or something like that) and when I debug it, the code runs without an error: I can F8 the code through but it takes forever to run it that way (I put a stapler to press F8 when I left for a lunch today and it was still only half way through when I came back about an hour later. When I'm running the code from my newer computer it only takes about a minute to handle the same file from start to finish).

Could it be the older machine is too slow for the macro to run normally? And if so, how could I slow down the macro so that the older computer could keep up with the code?
 

Excel Facts

How to fill five years of quarters?
Type 1Q-2023 in a cell. Grab the fill handle and drag down or right. After 4Q-2023, Excel will jump to 1Q-2024. Dash can be any character.
I would check your VBA references, it could be that the library on one machine does not match the other. In your VBE click Tools>References and see if there is anything that says "MISSING" If there is, uncheck it and try running the code again. That is the only thing I can think of that would cause something like this to happen.
 
Upvote 0
Thanks for the tip! I'll do that first thing in the morning.

Checking the references never even crossed my mind because usually the references are saved with the file/code and it's the same files files we're talking about (= the macro file, the original price list file and the data table, 3 different files all of them saved in the same folder on the server).
 
Upvote 0
The references seemed okay but this time I've got the exact error message: "Code execution has been interrupted". So it wasn't even a real error message but the older machine seems to be hallucinating that I'm trying to interrupt the code from running.

Googled for that and I found three possible solutions to fix it:
1) Press "Debug" button in the popup, then press [Ctrl+Break] twice when the macro is not running
2) Start each macro with "Application.EnableCancelKey = xlDisabled" (I'm already thinking I might end up with endless loops with this one)
3) Export the modules and save the workbook without them. Reopen the workbook and import the modules back to the workbook.

I think I'll try number three first and hope that'll fix it.
 
Upvote 0

Forum statistics

Threads
1,223,249
Messages
6,171,031
Members
452,374
Latest member
keccles

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