View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Chip Pearson Chip Pearson is offline
external usenet poster
 
Posts: 7,247
Default How to test text case for Upper/Lower/Proper

Try some code like the following:

Dim S As String
S = "whatever"
If StrComp(S, UCase(S), vbBinaryCompare) = 0 Then
Debug.Print "UPPER CASE"
ElseIf StrComp(S, LCase(S), vbBinaryCompare) = 0 Then
Debug.Print "lower case"
ElseIf StrComp(S, StrConv(S, vbProperCase), vbBinaryCompare) = 0
Then
Debug.Print "Proper Case"
Else
Debug.Print "Mixed case"
End If


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com





"JS" wrote in message
...
Hi All,
I'm trying to find a way to test case of certain text-strings
to see if they
are upper, lower, proper, etc., in a VBA in Excel (similar to
Word's VBA
Case functions (wdLowerCase, wdUpperCase, wdTitleSentence,
wdTitleWord) - it
would be nice to have Excel functions: IsTextUpper,
IsTextLower,
IsTextProper, etc.
Does anyone know how this may be done?
Thanks a lot - JS