How to find specific text within a string and remove everything before and after using space

crackod93

Board Regular
Joined
Aug 9, 2007
Messages
71
hi, need some help please, looking for a formula which will do this:

original text = Hello 123 3DA £14.99
output text = 3DA

original text = Hello 123 33DA £14.99
output text = 33DA

original text = Hello 123 333DA £14.99
output text = 333DA

basically find DA in the middle, then remove EVERYTHING after it and everything BEFORE + INCLUDING the space before it whilst keeping the unknown number of values where you see the 3's

thanks everyone!
 

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.
=mid(b6,find("~",substitute(b6," ","~",2)),find("~",substitute(b6," ","~",3))-find("~",substitute(b6," ","~",2))) Where the first entry is in cell B6, then copy down.
 
Upvote 0
=mid(b6,find("~",substitute(b6," ","~",2)),find("~",substitute(b6," ","~",3))-find("~",substitute(b6," ","~",2))) Where the first entry is in cell B6, then copy down.

thanks for sending this through, but im having some problems with this.

the string which im looking in may not always conform to what i had shown as the 'original text' some times the text before and after this can be different, the only thing i can rely upon is the DA part and that there WILL be a space before and after it

so basically i need to take wherever DA is found and find the space before that and remove everything before it including the space and then anything after the DA too

thanks again
 
Upvote 0
Hi,

=TRIM(MID(SUBSTITUTE(A1," ",REPT(" ",LEN(A1))),FIND("DA",SUBSTITUTE(A1," ",REPT(" ",LEN(A1))))-LEN(A1)+2,LEN(A1)))

Regards
 
Upvote 0
You could also try

=TRIM(RIGHT(SUBSTITUTE(LEFT(A1,FIND("DA",A1)+1)," ",REPT(" ",100)),100))
 
Last edited:
Upvote 0

Forum statistics

Threads
1,222,149
Messages
6,164,238
Members
451,882
Latest member
Bigtop

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