Formula to Find the Position of the Last Alpha Character in a Text String?

mcgrupp

Board Regular
Joined
Jan 15, 2015
Messages
66

I am looking to see if there is a simple formula that will return the position of the last alpha character in a text string. The text strings will be of varying lengths and will contain alphanumeric characters and spaces only. So one string might be: 123 45 Abcde 678

So I just want to return the postion of letter “e” in this case, but it could be any of the alpha characters ABCDEFGHIJKLMNOPQRSTUVWYZabcdefghijklmnopqrstuvwxyz for the cells in my column.

I am just trying to avoid a lengthy formula.
Thanks for any help provided.

 

Excel Facts

Enter current date or time
Ctrl+: enters current time. Ctrl+; enters current date. Use Ctrl+: Ctrl+; Enter for current date & time.
one possibility, with your string in E1


=LOOKUP(1E+100,LOOKUP(CODE(MID(UPPER(E1),ROW(INDIRECT("1:"&LEN(E1))),1)),ROW(65:90)),ROW(INDIRECT("1:"&LEN(E1))))
 
Upvote 0
One more thing if I can, I could feasibly use this any time to determine if a string contains an alpha character since I would return #N/A if there wasn't an alpha character, right?
 
Upvote 0
I think the formula offered by VBA Geek will fail in certain circumstances. For example, the formula will return 14 instead of 12 for the text string...

Code:
123 45 Abcde \ 678

Maybe...

Code:
=MATCH(2,1/(ABS((CODE(UPPER(MID(E1,ROW(INDIRECT("1:"&LEN(E1))),1)))-77.5))<=12.5))

...confirmed with CONTROL+SHIFT+ENTER.

Hope this helps!
 
Upvote 0
Enter this formula with Ctrl + Shift +Enter:

=LEN(A1)-MATCH(TRUE,MID(A1,LEN(A1)-ROW(INDIRECT("1:"&LEN(A1)))+1,1)>="A",0)+1
 
Upvote 0
Domenic, your formula worked as well. What exactly would cause VBA's formula to fail? The "/" character or the spaces in front or both? Thank you very much for your help.
 
Upvote 0
Tried it but got #N/A. Dom's formula should be just fine but thank you for responding Istvan.
 
Upvote 0
In my example, it's the "\" character that would cause it to fail. And, there are other non-alpha characters that would cause it to fail as well.
 
Upvote 0
Enter this formula with Ctrl + Shift +Enter:

=LEN(A1)-MATCH(TRUE,MID(A1,LEN(A1)-ROW(INDIRECT("1:"&LEN(A1)))+1,1)>="A",0)+1

For me it works. Did you confirm the formula with Ctrl + Shift + Enter?
Excel Workbook
AB
112a3 45 Abcde 67813
223sdfgtzt4564569
3353 345rtzrtzASDFS7Re2321
4sdf45d6
Sheet
 
Upvote 0

Forum statistics

Threads
1,215,955
Messages
6,127,926
Members
449,411
Latest member
AppellatePerson

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