Extracting specific text from string

richardthelionheart

Board Regular
Joined
Mar 25, 2016
Messages
95
Office Version
  1. 2016
Platform
  1. Windows
=TRIM(LEFT(SUBSTITUTE(MID(D189,FIND("1",D189),LEN(D189))," ",REPT(" ",5)),5))

I'm using this formula to extract text from a string that begins with 1. {after the word find we see 1}
This works fine except I now want to insert 1 or 2 where we see 1. So any text that begins with 1 or 2.
I'm not sure this is possible ??
I would appreciate any help.



<colgroup><col width="64"></colgroup><tbody>
</tbody>
 

Excel Facts

Return population for a City
If you have a list of cities in A2:A100, use Data, Geography. Then =A2.Population and copy down.
Hi,

Try this ,not tested...

Ctrl+Shift+Enter NOT just Enter :

=TRIM(LEFT(SUBSTITUTE(MID(D18,MIN(IFERROR(FIND({"1","2"},D18),"")),LEN(D18))," ",REPT(" ",5)),5))
 
Upvote 0
I'm confused as to exact procedure. Normally I copy the formula and paste into the workbook. I'm sorry but I would need detailed instructions as to how you mean, admiral
 
Upvote 0
Hi, here is another option you can try:

=TRIM(LEFT(SUBSTITUTE(MID(D189,FIND(" 1"," "&SUBSTITUTE(D189,"2","1")),LEN(D189))," ",REPT(" ",5)),5))
 
Upvote 0
Many thanks to the contributors. FormR - you solved it !!!!!!!!!! Great !!!!!!!!!! I'm really happy.
 
Upvote 0

Forum statistics

Threads
1,214,926
Messages
6,122,306
Members
449,079
Latest member
juggernaut24

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