Excel 2010 Vba Compile Error Procedure Too Large
Contents |
here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss the workings and policies of this site About Us Learn more compile error procedure too large vb6 about Stack Overflow the company Business Learn more about hiring developers or posting ads vba call a sub from another sub with us Stack Overflow Questions Jobs Documentation Tags Users Badges Ask Question x Dismiss Join the Stack Overflow Community Stack Overflow how to call a function in vba is a community of 4.7 million programmers, just like you, helping each other. Join them; it only takes a minute: Sign up Getting error Procedure too large in VBA Macros (Excel) up vote 8 down subroutine vba vote favorite 2 I am getting Procedure too Large Error in a VBA macro. I am using MS-Excel 2003. excel vba excel-vba excel-2003 share|improve this question edited Jul 12 '12 at 13:21 Gaffi 3,13162859 asked Jul 12 '12 at 10:49 Code Hungry 885144168 Please never write procedures that have more than 65534 lines of code. –GSerg Jul 12 '12 at 10:52 2 @GSerg: I believe it
Call Vba
is not the number of lines that matters. One can get that error in 4k lines as well. It is the size of the procedure. The procedure, when compiled cannot exceed 64kilobytes. Niraj, break your procedure down into smaller parts and if you have recorded a macro then delete irrelevant code. –Siddharth Rout Jul 12 '12 at 11:02 Thanks Siddharth –Code Hungry Jul 12 '12 at 11:38 1 More than 64kb. I'm impressed. And perplexed. –mkingston Jul 12 '12 at 14:40 add a comment| 1 Answer 1 active oldest votes up vote 23 down vote accepted 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 Sub Sample() Range("A1") = "Blah Blah" Range("A2") = "Blah Blah" Range("A3") = "Blah Blah" Range("A4") = "Blah Blah" Range("A5") = "Blah Blah" Range("A6") = "Blah Blah" Range("A7") = "Blah Blah" End Sub This code can be written as Sub Sample() For i = 1 To 7 Range("A" & i) = "Blah Blah" Next i End Sub Another example Sub Sample() Range("A1") = (Range("A1") * 10) + (Range("A1") + 30) + (Range("A1") / 30) Range("A5"
Tech Support Guy, we highly recommend that you visit our Guide for New Members. Solved: Excel Macros too large problem Discussion in 'Business
Ambiguous Name Detected
Applications' started by theseus75, Jun 24, 2008. Thread Status: Not open for excel vba global variable further replies. Advertisement theseus75 Thread Starter Joined: Jan 7, 2005 Messages: 275 I've recorded and combined a few macros into sub vba one and - while it is really large - I never thought anything of it until I got the following error while trying to run it: "Compile Error Procedure too large" http://stackoverflow.com/questions/11450232/getting-error-procedure-too-large-in-vba-macros-excel I can certainly split these up into separate procedures, but it would save time to have them all as one. Is there a way to override this error? I am using Windows XP w/ SP2 and Excel 2003. Thanks in advance for any help. theseus75, Jun 24, 2008 #1 OBP Trusted Advisor Joined: Mar 8, 2005 Messages: 19,075 It is probably quite possible https://forums.techguy.org/threads/solved-excel-macros-too-large-problem.724207/ that you can considerably reduce the size of the Macro by rewriting it. Recorded Macros are notorious for having superfluous code in them. If you post it I am sure that one of the Excel gurus can rewrite it for you, or at least point you in right direction. OBP, Jun 24, 2008 #2 Rollin_Again Joined: Sep 4, 2003 Messages: 4,866 Break the large macro into seperate subs and then call each of the separate subs from your main procedure. Doing it this way makes your code much easier to maintain and you can still execute all the code by running your main macro only. If you need more help please post your sample workbook or code and we'll take a look and offer more advice. Code: Sub MainMacro() Call Macro1 Call Macro2 Call Macro3 End Sub Sub Macro1() 'Your Code 'Your Code End Sub Sub Macro2() 'Your Code 'Your Code End Sub Sub Macro3() 'Your Code 'Your Code End Sub Regards, Rollin Rollin_Again, Jun 24, 2008 #3 theseus75 Thread Starter Joined: Jan 7, 2005 Messages: 275 Thanks for the help: that code worked perfectly, Rollin_Again. OBP:
360 games PC games https://support.microsoft.com/en-us/kb/983044 Windows games Windows phone games Entertainment All Entertainment http://answers.microsoft.com/en-us/msoffice/forum/msoffice_excel-mso_mac/compile-error-procedure-too-large/d5414976-7e5c-4d6e-8061-9603a446cd56 Movies & TV Music Business & Education Business Students & educators Developers Sale Sale Find a store Gift cards Products Software & services Windows Office Free downloads & security Internet compile error Explorer Microsoft Edge Skype OneNote OneDrive Microsoft Health MSN Bing Microsoft Groove Microsoft Movies & TV Devices & Xbox All Microsoft devices Microsoft Surface All Windows PCs & tablets PC accessories Xbox & games Microsoft Lumia All compile error procedure Windows phones Microsoft HoloLens For business Cloud Platform Microsoft Azure Microsoft Dynamics Windows for business Office for business Skype for business Surface for business Enterprise solutions Small business solutions Find a solutions provider Volume Licensing For developers & IT pros Develop Windows apps Microsoft Azure MSDN TechNet Visual Studio For students & educators Office for students OneNote in classroom Shop PCs & tablets perfect for students Microsoft in Education Support Sign in Cart Cart Javascript is disabled Please enable javascript and refresh the page Cookies are disabled Please enable cookies and refresh the page CV: {{ getCv() }} English (United States) Terms of use Privacy & cookies Trademarks © 2016 Microsoft
be down. Please try the request again. Your cache administrator is webmaster. Generated Sat, 15 Oct 2016 07:42:47 GMT by s_wx1094 (squid/3.5.20)