How to count number of code in VBA?

K

Kenji

Is there an easy way to count the number of VBA code other than doing it
manually?

Kenji
 
B

Bernie Deitrick

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
 
Top