search for lowercase letter in two-letter 'word'

P

ppeer

Hi There,

If I find a second character lowercase letter in a word, I have to
identify the cell Offset(-1,1).
The words are like: Mc, Mv, Np and are all positioned in column C.
Also there, we find words like MK,LP,ET.

haven't found a solution yet,

Regards
 
P

Paul

If I understand your request properly :

Find the ones you need like this

If cells(nRow,nCol).value <> UCase(cells(nRow,nCol).value) then

' Your code in here

endif

This will find occurences of lower case characters in your cell values.
 
J

JLGWhiz

This will find a lower case string character when you know what the
character will be:

Sub getshorty()
Dim lr As Long, sh As Worksheet, rng As Range
Dim c As Range
Set sh = ActiveSheet
lr = sh.Cells(Rows.Count, 3).End(xlUp).Row
Set rng = sh.Range("C2:C" & lr)
For Each c In rng
If InStr(1, c.Value, "d", vbBinaryCompare) = 2 Then
Set x = c.Offset(-1, 1)
MsgBox x.Address
End If
Next
End Sub


In this case, "d" was the character being searched.
 
J

JLGWhiz

If you only need to find lower case of the second letter and do not know the
character, then this should work.

Sub getshorty()
Dim lr As Long, sh As Worksheet, rng As Range
Dim c As Range
Set sh = ActiveSheet
lr = sh.Cells(Rows.Count, 3).End(xlUp).Row
Set rng = sh.Range("C2:C" & lr)
For Each c In rng
If Not IsEmpty(c) Then
i = Mid(c.Value, 2, 1)
If i = LCase(i) Then
Set x = c.Offset(-1, 1)
MsgBox x.Address
End If
End If
Next
End Sub
 
R

Rick Rothstein

What you ultimately want to do is not very clear from your posting. For
example... where is this "word" and what action do you envision when you say
"identify"? Perhaps this will help you out... here is a method that tests if
the second character in YourWord (assumed to be a 2-letter word) is lower
case or not...

If YourWord Like "?[a-z]" Then
MsgBox "The second letter of your word is lower case"
Else
MsgBox "The second letter of your word is upper case"
End If
 

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