View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.programming
Chip Pearson Chip Pearson is offline
external usenet poster
 
Posts: 7,247
Default VBA Question - Remove keywords from cell text

I should have added that you'll need to select the cells to be
changed prior to running the code.


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com


"Chip Pearson" wrote in message
...
Use code like the following:

Option Explicit
Option Compare Text

Sub AAA()
Dim Keywords As Variant
Dim Rng As Range
Dim Ndx As Long
Keywords = Array("Q Line", "120 VAC") ' add more keywords
here
For Each Rng In Selection.Cells
For Ndx = LBound(Keywords) To UBound(Keywords)
Rng.Value = Replace(Rng.Text, Keywords(Ndx), "")
Next Ndx
Next Rng
End Sub



--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com


"Scott Wagner" wrote in
message
...
I have a need to reduce the amount of text in a range of cells.
There are
certain keywords that are not necessay in the cells that if
removed the text
length would be acceptable.

How do I go about removing keywords from cell text with VBA?
This would
need to run in column G of my worksheet.

Here is an example: (keywords are "Q Line" & "120 VAC")

Befo
Q Line THQB 120 VAC 1 pole 20A

After:
THQB 1 pole 20A

Thanks in advance!