View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.programming
malik641[_5_] malik641[_5_] is offline
external usenet poster
 
Posts: 1
Default Search Text in Comments


Thanks Tom for the reply.
I tried what you gave me and I had to add a "End If" statement but that
was all. But when I try to run the Macro it gives me a 'Runtime Error 13
Type Mismatch' and I have NO CLUE what that means. I'm a true novice at
VB code (it's been 5 years since I've had to use it....so I kinda
forgot everything about it)

Just incase I did something wrong here's what I have in the VB Editor:

Sub AnalysisOfLeaves()
'Calculates amount of leavers from text in comments

Dim tot As Long, num As Long
Dim cmt As Comment
Dim sStr As String, iloc As Long
Dim iloc1 As Long, iloc2 As Long
Dim iloc3 As Long

tot = 0

For Each cmt In ActiveSheet.Comments
If Not Intersect(cmt.Parent, Range("C4:C44")) Is Nothing Then
sStr = cmt.Text
iloc1 = InStr(1, sStr, "Transfer Out", vbTextCompare)
iloc2 = InStr(1, sStr, "Transfers Out", vbTextCompare)
iloc3 = InStr(1, sStr, "V. Term", vbTextCompare)
iloc = iloc1 + iloc2 + iloc3
If iloc 0 Then
num = CLng(Left(sStr, iloc - 1))
tot = num + tot
End If
End If
Next

Range("C50") = tot

End Sub


--
malik641
------------------------------------------------------------------------
malik641's Profile: http://www.excelforum.com/member.php...o&userid=24190
View this thread: http://www.excelforum.com/showthread...hreadid=386198