I am getting Procedure too Large Error in a VBA macro.
I am using MS-Excel 2003.
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
You will get that error if your procedure is more than 64kb. These are some of the things that you can to compact your code
1) Get rid of repetitive code. See this example
This code can be written as
Another example
This code can be written as
This will ensure that you cut down on space and do not write repetitive code.
2) If you generated the code via the macro then you may get something like this. Get rid of the useless code like
ActiveWindow.ScrollRow = 8968The above can be written as
3) Declare you Objects so that you don’t have to keep on repeating them. See this example
This can be written as
4) Break Up your procedure if need be. and call the 2nd procedure from the 1st
5) Avoid using
.Selectand.ActivateThey not only make your code slow but also take a lot of space in your code if used extensively. How to avoid using Select in Excel VBA macros