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

What did Pito Salas invent?
Pito Salas, working for Lotus, popularized what would become to be pivot tables. It was released as Lotus Improv in 1989.
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,215,455
Messages
6,124,938
Members
449,197
Latest member
k_bs

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