So close to completing Search and Substitute function

white84

New Member
Joined
May 11, 2018
Messages
40
Office Version
  1. 365
Platform
  1. Windows
Hi! I need all text after an identifier "CPAL", which can vary in length and may have a : or ; after "CPAL" plus a space.

Example Text: 1
0 Retrofit A/C, 2/4/1/0.5 FOC IP, CPAL: HSE + W + B Parts + Structures

What I am trying is giving me the text before that identifier

=Mid(A2,1,SEARCH("CPAL",A2,1))
Returns
10 Retrofit A/C, 2/4/1/0.5 FOC IP, C

Ideally the formula would return
HSE + W + B Parts + Structures

Thanks in advance!!
 

Excel Facts

Repeat Last Command
Pressing F4 adds dollar signs when editing a formula. When not editing, F4 repeats last command.
Try moving the SEARCH to the second argument of MID (and setting the last argument to 255 to get all of the rest of the string). You'll probably have to add a constant to the Search.
 
Last edited:
Upvote 0
Edit:
The example text above has a formatting issue when I posted here. Lets try again.

10 Retrofit A/C, 2/4/1/0.5 FOC IP, CPAL: HSE + W + B Parts + Structures
 
Upvote 0
Try moving the SEARCH to the second argument of MID (and setting the last argument to 255 to get all of the rest of the string). You'll probably have to add a constant to the Search.

Perfect!! Thank you!!
 
Upvote 0
Try moving the SEARCH to the second argument of MID (and setting the last argument to 255 to get all of the rest of the string). You'll probably have to add a constant to the Search.

I thought I would be able to add an OR prefix to this corrected formula for one additional text criteria that may occur. (i.e. 8 new A/C, 1/4/1/1 50% disc IP, SUP: HSE only) where I would want to return SUP: HSE only

This gives me a value error.
=OR(MID($A$2,SEARCH("CPAL",$A$2,1),255)*MID($A$2,SEARCH("SUP",$A$2,1),255))

Again, thanks in advance!
 
Upvote 0
Gah! I accidentally copied the Excel suggested correction, which still doesn't work. This is what I meant to post.

=OR(MID(Sheet37!$A$2,SEARCH("CPAL",Sheet37!$A$2,1),255),MID(Sheet37!$A$2,SEARCH("SUP",Sheet37!$A$2,1),255))
 
Upvote 0
Posting my corrected formula for anyone else with a similar issue.

Example text pulling from
8 new A/C, 1/4/1/1 50% disc IP, SUP: HSE only
10 Retrofit A/C, 2/4/1/0.5 FOC IP, CPAL: HSE + W + B Parts + Structures

Code:
=IFERROR(MID(Sheet37!$A$2,SEARCH("CPAL",Sheet37!$A$2,1),255),MID(Sheet37!$A$2,SEARCH("SUP",Sheet37!$A$2,1),255))
 
Upvote 0

Forum statistics

Threads
1,224,822
Messages
6,181,164
Members
453,021
Latest member
Justyna P

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