Delete defined text in a column

A

Angus

I got a column for some "company names" but I want to remove those "Co",
"company", "inc." etc, or "Atlanta", "L.A.", etc; I put those "to be removed"
text in another column so that all text in this column will be removed from
the company name column, eg.

Newell co, L.A. should be read as Newell
IBM Global Services Ltd, USA should be read as IBM Global Services
Australia Home Depot Inc. should be read as Home Depot
 
J

Joel

Sub removefromname()
Const RemoveCol As String = "C"

RemoveString = Array("company", "inc.", "etc", "Atlanta", "L.A.")

Lastrow = Range(RemoveCol & Rows.Count).End(xlUp).Row
For RowCount = 1 To Lastrow
For Each MyStr In RemoveString
ColData = Range(RemoveCol & RowCount)
If InStr(ColData, MyStr) > 0 Then
ColData = Trim(Replace(ColData, MyStr, ""))
Range(RemoveCol & RowCount) = ColData
'remove exit if you need to replace multiple items
Exit For
End If
Next MyStr

Next RowCount
End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top