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

Select a hidden cell
Somehide hide payroll data in column G? Press F5. Type G1. Enter. Look in formula bar while you arrow down through G.
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,217,438
Messages
6,136,616
Members
450,022
Latest member
Joel1122331

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