Excel VBA - how to test if last character in a cell is a number

Hi,

I would be very grateful if you could suggest how I can use VBA to ascertain if the last character in a cell is a number (0 through to 9).

Many thanks in advance
Alison
alisonthomAsked:
Who is Participating?

Improve company productivity with a Business Account.Sign Up

x
 
Rgonzo1971Connect With a Mentor Commented:
HI,

result = right(myString, 1) Like "#"

Regards
0
 
Saqib Husain, SyedEngineerCommented:
Select the cell and run this macro

Sub testlastnum()
If Right(Selection, 1) <= "9" And Right(Selection, 1) >= "0" Then MsgBox "yes" Else MsgBox "no"
End Sub

Open in new window

0
 
Rgonzo1971Commented:
Hi,

You could also use

result = Selection Like "*#"

Regards
0
 
alisonthomAuthor Commented:
Thank you so much for the quick and very helpful answer.

The other response is also most appreciated.

Thanks
Alison
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.