if statement using alpha characters

  • Thread starter Thread starter mikey may
  • Start date Start date
M

mikey may

I am wanting to use an IF statment to check if a value of
the 3 digit of 'AccRef'is alphabetical using the following
code

AccRef = LGD12345

If Mid(AccRef, 3, 1) < "a" Or Mid(AccRef, 3, 1) > "z" Then

This doesn't seem to work properly and was wondering if
there is a different way of doing the above.

The 3rd digit will always be an alpha character
 
Mickey,

If LCASE and UCASE are the same, it's not a letter...

Sub Test()
Dim accref As String
accref = "LGD12345"
If UCase(Mid(accref, 3, 1)) = LCase(Mid(accref, 3, 1)) Then
MsgBox "Sorry. Not a letter"
End If
End Sub

It is also possible to do a similar test with in a worksheet formula:

= NOT(EXACT(UPPER(MID(A1,3,1)),LOWER(MID(A1,3,1))))
 

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

Similar Threads

IF Statment......Again!! 1
IF statements 1
if alpha character 3
Wildcards in If statements 4
Check for Alpha characters 4
Removing Trailing Alpha? 8
formula with alpha char in cell 7
Extract alpha from a cell 1

Back
Top