Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 81
Default Delete defined text in a column

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
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9,101
Default Delete defined text in a column


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
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
If text found in Row, delete Column JEFF Excel Programming 4 April 29th 07 10:24 PM
Delete empty spaces at the end of text of a column? nbaj2k[_33_] Excel Programming 1 August 8th 06 02:47 PM
How to delete row if column is blank or certain text Steve D. Excel Programming 5 January 6th 06 03:20 PM
Delete all rows where Column A contains Text D Hafer - TFE Excel Worksheet Functions 3 July 1st 05 06:03 PM
Delete rows with text and blanks in column A GJones Excel Programming 0 November 19th 03 10:36 PM


All times are GMT +1. The time now is 10:06 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"