title: Counting how many comments and how they are distributed in VBA code?
body: <p>I am looking to create some metrics about the quality of the VBA code I am writing, through different ratios of the actual code written and comment lines written.</p>
  
  <p>Ideally I am looking for a VBA script/function to detect the comment lines in Macro Enabled workbooks and Excel add-ins and being able to differentiate where the comments and code are written e.g. have the comment to code ratio for each module and form in a project.</p>
  
  <p>Below is the code I have so far, but I only managed to found how to give the total count of the lines and the count for the declaration lines. Is there something similar for comments?</p>
  
  <pre><code>Public Sub moduleInfo()
     Dim objModule As Object
     For Each objModule In Application.VBE.ActiveVBProject.VBComponents
         With objModule
             Debug.Print .Name, .CodeModule.CountOfLines, .CodeModule.CountOfDeclarationLines
         End With
     Next objModule
  End Sub
  </code></pre>