This will loop until a code module's name is entered or Cancel is pressed.
Sub countcod()
Dim MyCodeMod As Object
Dim x As String
Set MyCodeMod = Nothing
Do
x = InputBox("how many lines of code in? ", "get a numer of line code")
If StrPtr(x) = 0 Then Exit Sub: Rem Cancel pressed
On Error Resume Next
Set MyCodeMod = ActiveWorkbook.VBProject.VBComponents(x).CodeModule
On Error GoTo 0
If MyCodeMod Is Nothing Then
MsgBox "module do not exist,please try again", Title:="module is missing"
End If
Loop While MyCodeMod Is Nothing
MsgBox " your module has " & MyCodeMod.CountOfLines & " lines of code", vbInformation, "number of lines in a vba module"
End Sub