Code:
Dim ilSanityCheck As Integer
Dim llEndLine As Long

Set olPane = Application.VBE.ActiveCodePane
olPane.GetSelection Startline:=llSRow, startcolumn:=llSCol, Endline:=llERow, Endcolumn:=llECol

slProcName = olPane.CodeModule.ProcOfLine(llSRow, vbext_pk_Proc)
llLine1 = olPane.CodeModule.ProcBodyLine(slProcName, vbext_pk_Proc)
llCountLines = olPane.CodeModule.ProcCountLines(slProcName, vbext_pk_Proc)
llStartLine = olPane.CodeModule.ProcStartLine(slProcName, vbext_pk_Proc)
llEndLine = llStartLine + llCountLines - 1

' Find Dim Line.
llCompLine1 = llLine1

Do
  slOLine1 = Trim$(olPane.CodeModule.Lines(llCompLine1, 1))
  
  If Left$(slOLine1, 4) = "Dim " Then
    Exit Do
  ElseIf Left$(slOLine1, 6) = "Const " Then