top of page

VBA Code Limit


A module in Visual Basic for Excel cannot contain an unlimited amount of code. As Microsoft confirms in this posting on its Developer Network, the limit is 64 K.

If you enter VBA code in a module which exceeds this limit, you will get this message:

. . . indicating that the 64K threshold has been exceeded.

You can check the size of a module by using the VBA code posted here by RoyUK on OzGrid.

Simply enter this additional vba code, below the vba code you're checking. A dividing line should appear in the module. Press play with your cursor still in the HowBig code section.

Sub HowBig() Dim ModSize As Double ModSize = Len(Application.VBE.ActiveCodePane.CodeModule. _ Lines(1, Application.VBE.ActiveCodePane.CodeModule.CountOfLines)) / 1000 MsgBox ModSize End Sub

A separate message box will appear listing the VBA code size.

If you get an error reading, "Programmatic Access To Visual Basic Project Is Not Trusted", go to File . . . Options . . .Trust Center . . . Trust Center Settings, and then under Macro Settings check off the option for 'Trust Access to the VBA project object model.'.


 

Sean O'Shea has more than 20 years of experience in the litigation support field with major law firms in New York and San Francisco.   He is an ACEDS Certified eDiscovery Specialist and a Relativity Certified Administrator.

​

The views expressed in this blog are those of the owner and do not reflect the views or opinions of the owner’s employer.

​

If you have a question or comment about this blog, please make a submission using the form to the right. 

Your details were sent successfully!

© 2015 by Sean O'Shea . Proudly created with Wix.com

bottom of page