Sub CountCodeLines()
Dim VBCodeModule As Object
Dim NumLines As Long, N As Long
With ActiveWorkbook
For N = 1 To .VBProject.VBComponents.Count
Set VBCodeModule = .VBProject.VBComponents(N).CodeModule
NumLines = NumLines + VBCodeModule.CountOfLines
Next
End With
MsgBox "Total number of lines of code in the project = " & NumLines, , "Code Lines"
Set VBCodeModule = Nothing
End Sub