How can I detect if a character in a string is a letter or a number.

interner

New Member
Joined
Jun 20, 2011
Messages
44
Not an actual question, was getting no results in searching for the answer on the internet, but I figured it out! Maybe it can help someone along the way. Please don't punish me for posting a answer.

[/code]
Sub stringnumtest()
Dim thatsaletter As Boolean
somestring = "2p"
thatsaletter = IsNumeric(Right(somestring, 1))
If thatsaletter = True Then
MsgBox "yes"
Else
MsgBox "no"
End If
End Sub

Code:
You could obviously use any variation of string handling where the "right" function exists. Happy Friday!
 

Excel Facts

Select all contiguous cells
Pressing Ctrl+* (asterisk) will select the "current region" - all contiguous cells in all directions.
Here is something else you can play about with if you need to be more specific.

Each character has an ASCII number.
http://www.asciitable.com/

33-47.....Special characters
48-57.....numeric 0-9 inc
58-64.....Special characters
65-90.....A-Z upper case
91-96.....Special characters
97-122....a-z lower case
123-126

You could write a Function, containing a Select Case statement, returning a string denoting the type of character.

Just saying, like.

Bertie
 
Upvote 0

Forum statistics

Threads
1,206,753
Messages
6,074,741
Members
446,082
Latest member
fgiron83

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top