ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Letter recognition (https://www.excelbanter.com/excel-programming/389305-letter-recognition.html)

General[_2_]

Letter recognition
 
Is there a simple formula that can recognised the first character in a cell
as being a letter as opposed to a number or symbol?

Thanks.

Gary Keramidas

Letter recognition
 
one way

IsNumeric(Left(Range("A1").Value, 1))
will be true if the first character is a number, false if it's a character



--


Gary


"General" wrote in message
...
Is there a simple formula that can recognised the first character in a cell
as being a letter as opposed to a number or symbol?

Thanks.




Norman Jones

Letter recognition
 
Hi General,

Try:

'=============
Public Function IsFirstAlpha(sStr) As Boolean
Dim iAsc As Long

iAsc = Asc(Left(sStr, 1))

IsFirstAlpha = iAsc = 65 And iAsc <= 90 _
Or iAsc = 97 And iAsc <= 122
End Function
'<<=============

The function may be used from VBA:

'=============
Public Sub TestIt()
MsgBox IsFirstAlpha("ABC123")
End Sub
'<<=============

Alternatively, it may be used in Excel as a user
defined function (UDF):

=IsFirstAlpha(A1)


---
Regards,
Norman


"General" wrote in message
...
Is there a simple formula that can recognised the first character in a
cell
as being a letter as opposed to a number or symbol?

Thanks.





All times are GMT +1. The time now is 05:31 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com