Extracting specific characters from a string of text & numbers

Woobes

New Member
Joined
May 30, 2012
Messages
2
Any recommendation of a formula to get this please? I need to extract the first 2 or 3 characters from an alphanumeric string, but there is not a clear way I've found to do it. The formula needs to retrieve the first two characters only if the third is a number and if the third character is a letter, report the first 3. The first and second characters could be letters or numbers. For example I need to report the following:
ABC123 = ABC
AB1234 = AB
1AB234 = 1AB
2A1234 = 2A
A1234 = A1
Thanks for any advice
 

Excel Facts

Why does 9 mean SUM in SUBTOTAL?
It is because Sum is the 9th alphabetically in Average, Count, CountA, Max, Min, Product, StDev.S, StDev.P, Sum, VAR.S, VAR.P.
Welcome to MrExcel.

Try:

Code:
=IF(ISNUMBER(--MID(A1,3,1)),LEFT(A1,2),LEFT(A1,3))

Matty
 
Upvote 0
Oh wow - thanks Matty for the ultra quick response. That's just made the rest of my spreadsheet work so much better.
 
Upvote 0

Forum statistics

Threads
1,211,697
Messages
6,103,359
Members
447,861
Latest member
LllopezXC

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