How to count number of code in VBA?

  • Thread starter Thread starter Kenji
  • Start date Start date
Kenji,

The code below requires a reference to MS VBA extensibility, and will report
how many lines are in the activeworkbook.

HTH,
Bernie
MS Excel MVP

Sub CountLines()
Dim LineCount As Integer
Dim myVBAs As VBComponents
Dim myVBA As VBComponent

Set myVBAs = ActiveWorkbook.VBProject.VBComponents
For Each myVBA In myVBAs
LineCount = LineCount + myVBA.CodeModule.CountOfLines
Next
MsgBox "Lines of code for the activeworkbook is " & LineCount
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

Back
Top