Trim, Mid...?

orbea_adam

Well-known Member
Joined
Nov 15, 2005
Messages
500
Hi Guys, I have data formatted as "General" that looks like the following:

5144 / 22 - Both - LWRV

510 / 8 - Both - DO

5377 / 4 - Annual - LWRV

101 / 25 - Both - DO

How should I get rid of the spaces and keep just the numbers and " / "? I can think of trim, mid, left, right, but the number of characters will always vary as in the example.
Thanks
Adam
 

Excel Facts

Create a Pivot Table on a Map
If your data has zip codes, postal codes, or city names, select the data and use Insert, 3D Map. (Found to right of chart icons).

Seti

Well-known Member
Joined
May 19, 2002
Messages
2,916
Here's one way, assuming that there is a dash as shown:

=LEFT(SUBSTITUTE(A1," ",""),FIND("-",SUBSTITUTE(A1," ",""))-1)

It gets rid of all spaces, finds the dash and uses that in the left function.
 

orbea_adam

Well-known Member
Joined
Nov 15, 2005
Messages
500
Here's one way, assuming that there is a dash as shown:

=LEFT(SUBSTITUTE(A1," ",""),FIND("-",SUBSTITUTE(A1," ",""))-1)

It gets rid of all spaces, finds the dash and uses that in the left function.
Thank you
 

barry houdini

MrExcel MVP
Joined
Mar 23, 2005
Messages
20,825
I imagine you only need one SUBSTITUTE....

=SUBSTITUTE(LEFT(A1,FIND("-",A1&"-")-1)," ","")
 

orbea_adam

Well-known Member
Joined
Nov 15, 2005
Messages
500
I imagine you only need one SUBSTITUTE....

=SUBSTITUTE(LEFT(A1,FIND("-",A1&"-")-1)," ","")
Barry,
Thank you for the solution, but can you explain how it works, please?
Adam
 

Forum statistics

Threads
1,176,363
Messages
5,902,716
Members
434,990
Latest member
Peter Jeffrey Gale

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
Top