Data Cleaning with the search function

jimmy2times

Board Regular
Joined
Aug 8, 2014
Messages
69
Hello I have a column in my tab called company name that needs data cleaning. The data looks like this
Company ABC-London
Company DEF-Manchester
Company A Ltd
Company B Ltd.
Company C,

I want to remove everything after the company name EG hyphen, comma, full stop,place.

The formula I am using is =left(A2(search(",",A2)-1). This works if I have a hyphen and the town. EG Company ABC-London but will return a #value error for the other examples provided.

Can the formula be adjusted to clean the other data entries without returning an error message? So the result should e
Company ABC
Company DEF
Company A Ltd
Company B Ltd
Company C

Any help would be much appreciated.

Kind Regards
 

Excel Facts

Can you sort left to right?
To sort left-to-right, use the Sort dialog box. Click Options. Choose "Sort left to right"
Check this one !
Your data in A1
Code:
=SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(A1,"-"," "),".",""),",","")
 
Last edited:
Upvote 0
Hi jimmy2times,

Apologies - this is not the most beautiful solution but works fine on my side...

=IF(IFERROR(SEARCH("-",A1),FALSE),LEFT(A1,SEARCH("-",A1)-1),IF(IFERROR(SEARCH(",",A1),FALSE),LEFT(A1,SEARCH(",",A1)-1),IF(IFERROR(SEARCH(".",A1),FALSE),LEFT(A1,SEARCH(".",A1)-1),A1)))
 
Upvote 0
Or you can use these formula!

Code:
=SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(A1,$C$1," "),$C$2,""),$C$3,"")

$C$1 = -
$C$2 = .
$C$3 = ,

You can change character as you requirement! Further more you can add more character which you want to remove.


10ntlj6.jpg
 
Upvote 0
Hello Muhammad,

I think what Jimmy required is to see the following output:

Company ABC
Company DEF
Company A Ltd
Company B Ltd
Company C

...so he wanted the formula to return the text before "-", "." and "," signs.
 
Upvote 0
Hello Muhammad,

I think what Jimmy required is to see the following output:

Company ABC
Company DEF
Company A Ltd
Company B Ltd
Company C

...so he wanted the formula to return the text before "-", "." and "," signs.


OOOPS sorry brother I understand it wrongly !
 
Upvote 0
That's ok! Give it one more try - my function works but it's very lengthy and there must be an easier way to do that...
 
Upvote 0
Thanks for looking at but not quite what is required?

Do you have a simpler version of the formula offered by justynaMk?
 
Upvote 0
Thanks for looking at but not quite what is required?

Do you have a simpler version of the formula offered by justynaMk?

A combined version works

=IF(IFERROR(SEARCH("-",A1),FALSE),LEFT(A1,SEARCH("-",A1)-1),SUBSTITUTE(SUBSTITUTE(A1,".",""),",",""))

It certainly compresses the formula
 
Upvote 0

Forum statistics

Threads
1,220,965
Messages
6,157,119
Members
451,398
Latest member
rjsteward

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