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

Remove leading & trailing spaces
Save as CSV to remove all leading and trailing spaces. It is faster than using TRIM().
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.
 
Upvote 0
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
 
Upvote 0
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
 
Upvote 0

Forum statistics

Threads
1,214,908
Messages
6,122,187
Members
449,071
Latest member
cdnMech

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