detect upper and lower case letters

M

mike allen

i need to tell if the first letter in a text string is capital or lower
case. i have figured out how to do this in the spreadsheet, but now need it
in code. i tried converting my spreadsheet formula to code, but doesn't
work:
If Application.exact(Left(Application.UPPER(Range("A1")), 1),
Left(Range("A1"), 1)) = True Then
Range("b1") = "upper case"
Else
Range("b1") = "lower case"
End If
any thoughts? thanks, mike allen
 
F

Frank Kabel

Hi
try
with Activesheet.Range("A1")
if ucase(left(.value,1))=left(.value,1) then
.offset(0,1).value="Upper case"
else
.offset(0,1).value="Lower case"
end if
end with
 
B

Bob Phillips

If UCase(Left(Range("A1"),1)) = Left(Range("A1"),1) Then
Range("b1") = "upper case"
Else
Range("b1") = "lower case"
End If


--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)
 
C

Cecilkumara Fernando

mike allen,
One way,
Sub LetterCase()
For Each Cell In Selection
If Left(Cell.Value, 1) = _
UCase(Left(Cell.Value, 1)) Then
Cell.Offset(0, 1).Value = "Upper Case"
Else
Cell.Offset(0, 1).Value = "Lower Case"
End If
Next Cell
End Sub

Cecil
 

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