-
GTO could you add some comment to your code? I would like to learn abit more about the use of VBScript.RegExp. I would have gone for something like this which is probably slower. Dave
[VBA]
Sub StrLen()
Dim Flag As Boolean, Lastrow As Integer, Cnt As Integer
Dim i As Integer, OutputCnt As Integer
Flag = False 'counter switch
Lastrow = 10 'row length adjust
OutputCnt = 0
For Cnt = 1 To Lastrow 'loop rows
'loop cell contents
For i = 1 To Len(Sheets("Sheet1").Range("A" & Cnt).Value)
If Flag = False Then
'search for "(" (ie. Asc 40) as start of search text
If Asc(Mid(Sheets("Sheet1").Range("A" & Cnt).Value, i, 1)) = 40 Then
Flag = True
End If
Else
'search for ")" (ie. Asc 40) as end of search text
If Asc(Mid(Sheets("Sheet1").Range("A" & Cnt).Value, i, 1)) = 41 Then
'Sheets("Sheet1").Range("B" & Cnt).Value = OutputCnt
MsgBox "This many letters: " & OutputCnt
Flag = False
OutputCnt = 0
Exit For
End If
OutputCnt = OutputCnt + 1
End If
Next i
Next Cnt
End Sub
[/VBA]
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules