View Single Post
  #4   Report Post  
Posted to microsoft.public.excel.programming
NickHK NickHK is offline
external usenet poster
 
Posts: 4,391
Default Searching for Capital Letters

Here's one way :
Public Function FirstCapitalLetter(argStr As Variant, Optional StartAt As
Long = 1) As Long
Dim LowerCase As String
Dim i As Long

LowerCase = LCase(argStr)

For i = StartAt To Len(LowerCase)
If Mid(LowerCase, i, 1) < Mid(argStr, i, 1) Then
FirstCapitalLetter = i
Exit Function
End If
Next

FirstCapitalLetter = 0
End Function

Seems OK. Not sure how all characters are handled in non-English text
though. You'd need to test.

NickHK

"F. Lawrence Kulchar" wrote in
message ...
How do I find the position of the FIRST...(or fifth) capital letter within

a
text string?

EG:

A

1 abndHnmJ
2 123wTTghy6TH
3 hhhHhhh

ANSWER: A1 would be 5
A2 would be 5
A3 would be 4

HOW TO TEST FOR THIS??

Thank you,

FLKulchar