Limit on Number of Lines of VBA Code?


Mark D'Agosta

I know there are certain VBA limits that don't exist in the standard Visual
Basic Development Environment (e.g. number of Line Continuation characters
in the same subroutine), but is there a limit to the number of lines of VBA
code that can exist within a single Excel workbook??? I'm currently using
Excel 2002.


Mark D'Agosta
(e-mail address removed)



Dick Kusleika


I would guess it's available memory. I just added 10,000 lines to a module
with no problem.

Sub testlines()

Dim i As Long
Dim vbc As VBComponent
Dim vbp As VBProject
Dim wb As Workbook

Set wb = Workbooks.Add

Set vbc = wb.VBProject.VBComponents.Add(vbext_ct_StdModule)

For i = 1 To 10000
vbc.CodeModule.InsertLines 1, "'" & i
Next i

End Sub

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question