Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Check to see if entire string is UpperCase?
I know I can check if an individual character is uppercase If X Like "[A-Z]"
but is there a way to check if a string of indeterminate length is all uppercase? |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Check to see if entire string is UpperCase?
if ucase(myStr) = mystr then
'it looks the same as uppercase But if your string looks like: myStr = "7!@#$_-==--" Then upper/lower case doesn't really make sense. msnyc07 wrote: I know I can check if an individual character is uppercase If X Like "[A-Z]" but is there a way to check if a string of indeterminate length is all uppercase? -- Dave Peterson |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
Check to see if entire string is UpperCase?
If myString = UCase(Mystring) then 'the string is fully uppercase
HTH, Keith "msnyc07" wrote: I know I can check if an individual character is uppercase If X Like "[A-Z]" but is there a way to check if a string of indeterminate length is all uppercase? |
#4
Posted to microsoft.public.excel.programming
|
|||
|
|||
Check to see if entire string is UpperCase?
The Like operator allows wildcards...
If Not X Like "*[a-z]*" Then ' X does not contain any lower case letters which ' doesn't mean every letter is an upper case letter... ' there could be punctuation marks or blanks Else ' X does not contain any lower case letters End If -- Rick (MVP - Excel) "msnyc07" wrote in message ... I know I can check if an individual character is uppercase If X Like "[A-Z]" but is there a way to check if a string of indeterminate length is all uppercase? |
#5
Posted to microsoft.public.excel.programming
|
|||
|
|||
Check to see if entire string is UpperCase?
"msnyc07" wrote:
I know I can check if an individual character is uppercase If X Like "[A-Z]" but is there a way to check if a string of indeterminate length is all uppercase? Both of the of following should work, assuming s is String and isUCase is Boolean. I don't know which is more efficient. isUCase = (s Like "*[A-Z]*" And Not s Like "*[a-z]*") isUCase = (s = UCase(s) And s < LCase(s)) Note that these return False for a string without any uppercase character. |
#6
Posted to microsoft.public.excel.programming
|
|||
|
|||
Check to see if entire string is UpperCase?
' X does not contain any lower case letters which
' doesn't mean every letter is an upper case letter... ' there could be punctuation marks or blanks The above comment should have read this way (with the correction shown in upper case)... ' X does not contain any lower case letters which ' doesn't mean every CHARACTER is an upper case letter... ' there could be punctuation marks or blanks -- Rick (MVP - Excel) "Rick Rothstein" wrote in message ... The Like operator allows wildcards... If Not X Like "*[a-z]*" Then ' X does not contain any lower case letters which ' doesn't mean every letter is an upper case letter... ' there could be punctuation marks or blanks Else ' X does not contain any lower case letters End If -- Rick (MVP - Excel) "msnyc07" wrote in message ... I know I can check if an individual character is uppercase If X Like "[A-Z]" but is there a way to check if a string of indeterminate length is all uppercase? |
#7
Posted to microsoft.public.excel.programming
|
|||
|
|||
Check to see if entire string is UpperCase?
On 2/17/2010 6:23 PM, msnyc07 wrote:
I know I can check if an individual character is uppercase If X Like "[A-Z]" but is there a way to check if a string of indeterminate length is all uppercase? Just to throw this out in case one uses 'Option Compare' Option Explicit Option Compare Text Sub Demo() Dim s s = "abC" 'True, but not correct Debug.Print UCase(s) = s 'False..Correct Debug.Print SameQ(s, UCase(s)) End Sub Function SameQ(s1, s2) SameQ = StrComp(s1, s2, vbBinaryCompare) = 0 End Function = = = = = = = HTH :) Dana DeLouis |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Changing the entire contents of my spreadsheet to uppercase | Excel Discussion (Misc queries) | |||
How do change entire worksheet to uppercase letters and lock it | Excel Worksheet Functions | |||
Can I make an entire column Uppercase? | Excel Discussion (Misc queries) | |||
anyway to change an entire document to uppercase in excel? | Excel Discussion (Misc queries) | |||
How can I convert entire columns of text to Uppercase in Excel? | Excel Worksheet Functions |