this should work for you
Code
-------------------
Option Explicit
Dim i As Integer
Dim j As Integer
Dim k As Integer
Dim CountOfHomers As Integer
Dim StringOfData As String
Sub SortTheThingys()
CountOfHomers = 0
j = 1
i = 0
k = 0
StringOfData = "Derek Jeter (3, Bonderman), Alfonso ... (6, Roney)"
For i = 1 To Len(StringOfData) ' cycle through each charachter in the string
If Mid(StringOfData, i, 1) = "(" Then ' if you hit a bracket
j = j + 1 ' add one to brackets
If k * 2 < j Then ' if number of <sets of runs is less than 2 X brackets
CountOfHomers = CountOfHomers + 1 ' add a run on
k = k + 1 ' add one to the number of sets of runs
End If
End If
If Mid(StringOfData, i, 1) = ")" Then j = j + 1 ' add one to number of brackets
If IsNumeric(Mid(StringOfData, i, 1)) = True And j Mod 2 < 0 Then ' if its a number and brackets are not even
CountOfHomers = CountOfHomers + Mid(StringOfData, i, 1) ' add on that number
'(i dont play baseball but i assumed no player would get more than 9 homeruns
'in one game,:P)
k = k + 1 ' add one to the number of sets of runs
End If
Next i
Range("a1").Value = CountOfHomers
End Su
-------------------
g
--
irishboy
-----------------------------------------------------------------------
irishboyx's Profile:
http://www.excelforum.com/member.php...fo&userid=3249
View this thread:
http://www.excelforum.com/showthread.php?threadid=52284