PC Review


Reply
Thread Tools Rate Thread

Delete defined text in a column

 
 
Angus
Guest
Posts: n/a
 
      25th Jan 2008
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
 
Reply With Quote
 
 
 
 
Joel
Guest
Posts: n/a
 
      25th Jan 2008

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

"Angus" wrote:

> 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

 
Reply With Quote
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Delete row if column A cell text length is not 11 John Keith Microsoft Excel Programming 4 1st Oct 2008 02:12 AM
Inserting pre-defined text at pre-defined location upon tick! =?Utf-8?B?Z2lhbm5p?= Microsoft Word Document Management 4 2nd Jun 2007 12:03 AM
If text found in Row, delete Column =?Utf-8?B?SkVGRg==?= Microsoft Excel Programming 4 29th Apr 2007 10:24 PM
How to delete row if column is blank or certain text =?Utf-8?B?U3RldmUgRC4=?= Microsoft Excel Programming 5 6th Jan 2006 03:20 PM
Delete all rows where Column A contains Text =?Utf-8?B?RCBIYWZlciAtIFRGRQ==?= Microsoft Excel Worksheet Functions 3 1st Jul 2005 06:03 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 10:22 PM.