Extracting text and numbers out of a string

Peter Davison

Active Member
Joined
Jun 4, 2020
Messages
444
Office Version
  1. 365
Platform
  1. Windows
I have a string in a cell (see below)
PL-AF4-01B-M-Aflex
Firstly I want to extra just the AF4 and I used the following formula -
=RIGHT(LEFT(U2,6),3)
It works, but I just wanted to check if this Is this the correct way of doing it?

Secondly
Same string, I wanted to extract 01 and I used this formula -
=RIGHT(TEXTJOIN("",TRUE,IFERROR((MID(U2,ROW(INDIRECT("1:"&LEN(U2))),1)*1),"")),2)
I feel sure I may have gone a long winded way of doing it.
It does work, but is there a simpler formula?

Really appreciate your help.
 

Excel Facts

Create a Pivot Table on a Map
If your data has zip codes, postal codes, or city names, select the data and use Insert, 3D Map. (Found to right of chart icons).
One example is not usually enough to go on, but if your strings are always composed at the beginning with 2 characters, a dash, 3 characters, a dash then the two digits you want, then try these those formulas...

=MID(U2,4,3)

=MID(U2,8,2)
 
Upvote 0
Solution
Wow, how simple to do.
I was ages trying to work it out.
I couldn't see anything like that on google but maybe my search wasn't very good.
Thank you so much for your time.
 
Upvote 0

Forum statistics

Threads
1,215,750
Messages
6,126,666
Members
449,326
Latest member
asp123

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