Extract text within a String

Pradeep

New Member
Joined
Sep 4, 2007
Messages
7
Hi,

I have following type of data:

Range A1: ABCD XXX 18-Feb 11 09:24 - xyz
Range A2: MN XXX 18-Feb 11 09:24 - xy
Range A3: EF XXXXXX 18-Feb 11 09:24 - st

These are details entered by the users after investigation. Information before the date in each of the cell is a fail code. The length of the fail code is not constant.

In the above case Fail code for the respective cells are as follows:
Range A1: ABCD XXX
Range A2: MN XXX
Range A3: EF XXXXXX

I am interested in a formula which can help me segregate the fail code from the text in each of the cell. This is a huge file and appreciate help in this regard.

Please advise
 

Excel Facts

Copy PDF to Excel
Select data in PDF. Paste to Microsoft Word. Copy from Word and paste to Excel.
Aladin - You are a STAR. This works.

However, there is one change here. There are a few fail codes which have multiple spaces. Ex-

Range A1: AB CD XXX 18-Feb 11 09:24 - xyz
Range A2: MN XXX 18-Feb 11 09:24 - xy
Range A3: EF XX XX XX 18-Feb 11 09:24 - st.

If I use the formula advised by you, it would return

Range A1: AB CD instead of AB CD XXX and
Range A3: EF XX instead of EF XX XX XX.

Apologies for not providing this information first time.
 
Upvote 0
Aladin - You are a STAR. This works.

However, there is one change here. There are a few fail codes which have multiple spaces. Ex-

Range A1: AB CD XXX 18-Feb 11 09:24 - xyz
Range A2: MN XXX 18-Feb 11 09:24 - xy
Range A3: EF XX XX XX 18-Feb 11 09:24 - st.

If I use the formula advised by you, it would return

Range A1: AB CD instead of AB CD XXX and
Range A3: EF XX instead of EF XX XX XX.

Apologies for not providing this information first time.

Does...

=LEFT(TRIM(A2),FIND("#",SUBSTITUTE(TRIM(A2)," ","#",2))-1)

resolve the issue?
 
Upvote 0
Hey Pradeep,

This might work too

=LEFT(A1,FIND(UPPER("X "),A1))

Regards,
Ron...
 
Upvote 0
How about

=TRIM(LEFT(A1,FIND("-",A1)-3))

Assuming that the day part of teh date is always followed by "-" if the date is in the form 09-Feb this works as TRIM gets rid of the space and if it is in the form 9-Feb it also works
 
Upvote 0

Forum statistics

Threads
1,224,566
Messages
6,179,558
Members
452,928
Latest member
101blockchains

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