Procedure Too Large Error on One Computer but NOT the Other

biocentrism

Board Regular
Joined
Jul 28, 2014
Messages
187
Hello

I am getting a 'Compile Error: Procedure too large' when I run a VBA program on one computer.

But when I run the exact same program on another computer it runs fine.

I know the Procedure too large error is when the code is too long and it is a very large program. But it is strange that it generates the error for only 1 computer and not the other.

Is there a setting or something about the computer itself that would explain this so that I can get it to run?

Thank you.
 

Excel Facts

Who is Mr Spreadsheet?
Author John Walkenbach was Mr Spreadsheet until his retirement in June 2019.
My guess would be one computer being 64-bit and the other being 32-bit. You might try splitting up a long sub into several little ones and then have a main sub call each little one in order.
 
Upvote 0
Thanks for your reply but hey are both running 64-bit.

I would try to split the code up but it is a very involved program and it will take me a while to do and debug. And I am traveling at the moment and cannot do it from this laptop.

Was hoping someone would know if there was a setting or something that might cause one computer to compile the exact same code differently than another would.

What is more strange is that this code used to compile fine before when I ran it a month ago on this computer. But something seems to have changed.
 
Upvote 0
This might sound crazy, but does it compile if you copy/paste all of the code into a brand new module, delete the old module, and rename the new module to the name of the old module that you just deleted?
 
Upvote 0
This might sound crazy, but does it compile if you copy/paste all of the code into a brand new module, delete the old module, and rename the new module to the name of the old module that you just deleted?

WOW THAT WORKED (kinda of)! Thank you SO much for this advice. It has saved me a lot of aggravation during my trip!!!

The 'kinda of' part is that the program works if I run right after doing as you suggested without Saving the file. But if I save the workbook and run it, I get the same old error as before. So it seems that the 'Save' is what 'corrupts' the file and prevents it from working.

While I can do as you suggested for the remainder of this trip, long-term I need to fix this as I run the file every day.

Do you have any idea why the Save would corrupt a file that would otherwise run successfully pre-Save?
 
Upvote 0
I had a hunch based on some information I remember reading. I searched all over the internet for it but couldn't find it again, so I may be wrong or even a little vague.

Pretty much Office saves your Modules in a "compiled" state. The internet generally agrees this size can't go beyond 64MB, though that isn't documented. As you keep making changes the code gets recompiled but in a way that doesn't get compacted correctly. When you erase the code and put it into a new module you get rid of all of the inefficiencies in compiling because it does the whole thing, not just your changes. Frankly it's as cryptic to me as database indexes needing rebuilt or databases needing compacted.

For a long term solution you'll need to find ways to break the large method into several different smaller methods. Beyond that I'm not sure what else you can do.
 
Upvote 0
That makes sense. Thanks again for you help LockeGarmin. You really saved me a lot of trouble. I really appreciate it!
 
Upvote 0

Forum statistics

Threads
1,223,911
Messages
6,175,326
Members
452,635
Latest member
laura12345

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