Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9
Default 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   Report Post  
Posted to microsoft.public.excel.programming
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




  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9
Default 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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Changing multiple cell text from lower case to upper case Patti Excel Discussion (Misc queries) 2 January 4th 08 08:35 PM
vlookup -- Upper case and Lower case text teec_detroit Excel Discussion (Misc queries) 1 August 6th 07 04:40 PM
Upper, Lower & Proper case VBA Noob[_17_] Excel Programming 2 July 8th 06 11:18 AM
Change the text from lower case to upper case in an Excel work boo dave01968 Excel Discussion (Misc queries) 2 December 9th 05 09:09 AM
How do I change existing text from lower case to upper case CT Cameron Excel Discussion (Misc queries) 2 November 30th 04 01:07 AM


All times are GMT +1. The time now is 11:04 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"