Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
How to test text case for Upper/Lower/Proper
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 |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
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 |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
How to test text case for Upper/Lower/Proper
Hi Chip
Thanks, thanks, thanks... works like a charm... Nothing like one who knows... Cheers & thanks again, JS "Chip Pearson" wrote in message ... 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 |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Changing multiple cell text from lower case to upper case | Excel Discussion (Misc queries) | |||
vlookup -- Upper case and Lower case text | Excel Discussion (Misc queries) | |||
Upper, Lower & Proper case | Excel Programming | |||
Change the text from lower case to upper case in an Excel work boo | Excel Discussion (Misc queries) | |||
How do I change existing text from lower case to upper case | Excel Discussion (Misc queries) |