Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 102
Default Test if Last Character in Column of Cells is Alpha Character

How do I test if the last character in Column A is a Alpha Character
Sample cell: 0238:H601X or 0238:T0624
the numbers in the cell still will show up as Text format.
How can I do an excel formula or VBA to give me a true/false if the last
character is an alpha(letter)?
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 8,520
Default Test if Last Character in Column of Cells is Alpha Character

Try the below

Sub Macro()
If Right(Trim(Range("A1")), 1) Like "[A-Za-z]" Then
MsgBox "Alpha"
End If
End Sub

If this post helps click Yes
---------------
Jacob Skaria


"Benjamin" wrote:

How do I test if the last character in Column A is a Alpha Character
Sample cell: 0238:H601X or 0238:T0624
the numbers in the cell still will show up as Text format.
How can I do an excel formula or VBA to give me a true/false if the last
character is an alpha(letter)?

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9,101
Default Test if Last Character in Column of Cells is Alpha Character

You can use not isnumeric()

If not isnumeric(Right(Trim(Range("A1")), 1)) Then

or

If isnumeric(Right(Trim(Range("A1")), 1)) Then


The trim is needed if there may be blanks at the end of the string.


"Benjamin" wrote:

How do I test if the last character in Column A is a Alpha Character
Sample cell: 0238:H601X or 0238:T0624
the numbers in the cell still will show up as Text format.
How can I do an excel formula or VBA to give me a true/false if the last
character is an alpha(letter)?

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,934
Default Test if Last Character in Column of Cells is Alpha Character

An even simpler construction for the test...

Sub Macro()
If Range("A1") Like "*[A-Za-z]" Then
MsgBox "Alpha"
End If
End Sub

By the way, I removed the TRIM function call because that would mask the
fact that the string ended with something other than an alpha character.

--
Rick (MVP - Excel)


"Jacob Skaria" wrote in message
...
Try the below

Sub Macro()
If Right(Trim(Range("A1")), 1) Like "[A-Za-z]" Then
MsgBox "Alpha"
End If
End Sub

If this post helps click Yes
---------------
Jacob Skaria


"Benjamin" wrote:

How do I test if the last character in Column A is a Alpha Character
Sample cell: 0238:H601X or 0238:T0624
the numbers in the cell still will show up as Text format.
How can I do an excel formula or VBA to give me a true/false if the last
character is an alpha(letter)?


  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 8,520
Default Test if Last Character in Column of Cells is Alpha Character

Yes; thereby can avoid the usage of RIGHT(); but hope the OP would want to
ignore any spaces at the end..

If this post helps click Yes
---------------
Jacob Skaria


"Rick Rothstein" wrote:

An even simpler construction for the test...

Sub Macro()
If Range("A1") Like "*[A-Za-z]" Then
MsgBox "Alpha"
End If
End Sub

By the way, I removed the TRIM function call because that would mask the
fact that the string ended with something other than an alpha character.

--
Rick (MVP - Excel)


"Jacob Skaria" wrote in message
...
Try the below

Sub Macro()
If Right(Trim(Range("A1")), 1) Like "[A-Za-z]" Then
MsgBox "Alpha"
End If
End Sub

If this post helps click Yes
---------------
Jacob Skaria


"Benjamin" wrote:

How do I test if the last character in Column A is a Alpha Character
Sample cell: 0238:H601X or 0238:T0624
the numbers in the cell still will show up as Text format.
How can I do an excel formula or VBA to give me a true/false if the last
character is an alpha(letter)?





  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 102
Default Test if Last Character in Column of Cells is Alpha Character

YES! that worked so good! Just what I needed. Thanks Jacob!

"Jacob Skaria" wrote:

Try the below

Sub Macro()
If Right(Trim(Range("A1")), 1) Like "[A-Za-z]" Then
MsgBox "Alpha"
End If
End Sub

If this post helps click Yes
---------------
Jacob Skaria


"Benjamin" wrote:

How do I test if the last character in Column A is a Alpha Character
Sample cell: 0238:H601X or 0238:T0624
the numbers in the cell still will show up as Text format.
How can I do an excel formula or VBA to give me a true/false if the last
character is an alpha(letter)?

  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,934
Default Test if Last Character in Column of Cells is Alpha Character

Just one follow up question. The formula, as Jacob has presented it to you,
will ignore all trailing blank spaces at the end of your text string... is
that acceptable to you?

--
Rick (MVP - Excel)


"Benjamin" wrote in message
...
YES! that worked so good! Just what I needed. Thanks Jacob!

"Jacob Skaria" wrote:

Try the below

Sub Macro()
If Right(Trim(Range("A1")), 1) Like "[A-Za-z]" Then
MsgBox "Alpha"
End If
End Sub

If this post helps click Yes
---------------
Jacob Skaria


"Benjamin" wrote:

How do I test if the last character in Column A is a Alpha Character
Sample cell: 0238:H601X or 0238:T0624
the numbers in the cell still will show up as Text format.
How can I do an excel formula or VBA to give me a true/false if the
last
character is an alpha(letter)?


Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
if alpha character samuel Excel Discussion (Misc queries) 4 December 17th 08 03:22 AM
Incrementing an alpha character Francis Hookham Excel Programming 11 October 9th 07 07:00 PM
test if a character in a string is alpha Matilda Excel Programming 7 October 16th 06 02:36 PM
All possible Alpha character combonations [email protected] Excel Programming 4 September 24th 06 04:22 PM
Increment Alpha Character Dan Excel Programming 4 June 3rd 04 07:32 PM


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

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"