Formula to extract text and add text

geigMR

Board Regular
Joined
Sep 27, 2011
Messages
51
I need to be able to extract a left portion of text; and as well as this add some text at the end based on whether the cell contains a certain code, i.e. “*XXZ” or just “*XX”<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" /><o:p></o:p>
<o:p> </o:p>
I’ve achieved the first part of this but not the second…<o:p></o:p>
<o:p> </o:p>
Example:<o:p></o:p>
A1: AB123*XXZ-XXZ 0<o:p></o:p>
A2: DFG323*XX-XX 5<o:p></o:p>
A3: COOK-EF45678*XX-XXY 88<o:p></o:p>
<o:p> </o:p>
What I want to end up with is:<o:p></o:p>
B1: AB123-toast<o:p></o:p>
B2: DFG323-jam<o:p></o:p>
B3: COOK-EF45678-jam<o:p></o:p>
<o:p> </o:p>
“-toast” being the replacement for “*XXZ”, and “-jam” being the replacement for “*XX”. Every single cell will have one or other of these two codes.<o:p></o:p>
<o:p> </o:p>
I know how to do the first part of the formula:<o:p></o:p>
=LEFT(A1,FIND("*",A1,1)-1)<o:p></o:p>
<o:p> </o:p>
This gives me:<o:p></o:p>
B1: AB123<o:p></o:p>
B2: DFG323<o:p></o:p>
B3: COOK-EF45678<o:p></o:p>
<o:p> </o:p>
But does anyone know how to add the “-toast” and “-jam” ?<o:p></o:p>
<o:p> </o:p>
A thousand thank yous to any helpers!<o:p></o:p>
:)
 

Excel Facts

How to calculate loan payments in Excel?
Use the PMT function: =PMT(5%/12,60,-25000) is for a $25,000 loan, 5% annual interest, 60 month loan.

Forum statistics

Threads
1,224,586
Messages
6,179,723
Members
452,939
Latest member
WCrawford

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