Check for case of string

M

msnyc07

So as I work with this VBA from coder I see you can set case of string

Is there anyway to examine case? Either If All Uppercase or if Mixed/Init
Caps is fine either way I can continue my logic.

Thanks!
 
D

Dave Peterson

Check your other post.
So as I work with this VBA from coder I see you can set case of string

Is there anyway to examine case? Either If All Uppercase or if Mixed/Init
Caps is fine either way I can continue my logic.

Thanks!
 
R

Ron Rosenfeld

So as I work with this VBA from coder I see you can set case of string

Is there anyway to examine case? Either If All Uppercase or if Mixed/Init
Caps is fine either way I can continue my logic.

Thanks!

First letter Cap:

Dim s as String
Left(s, 1) Like "[A-Z]"

That might cover everything you need.

If you need to be sure that if the first letter is capitalized, the rest are
either ALL caps or ALL non-caps, then perhaps:

Dim s as String
Left(s, 1) Like "[A-Z]" And _
(Mid(s, 2) = UCase(Mid(s, 2)) Or Mid(s, 2) = LCase(Mid(s, 2)))
--ron
 
M

Mike H

Hi,

Try this

If mystring = UCase(mystring) Then
MsgBox "all uppercase"
Else
MsgBox "Mixed case"
End If

--
Mike

When competing hypotheses are otherwise equal, adopt the hypothesis that
introduces the fewest assumptions while still sufficiently answering the
question.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top