View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.programming
Stuart[_5_] Stuart[_5_] is offline
external usenet poster
 
Posts: 413
Default Point Me. Searching strings for lists of keywords

It would be of great help to me, if you could demonstate
the technique for the situation where multiple keywords
could exist within the same cell.

Regards.

"J.E. McGimpsey" wrote in message
...
One way:

Public Sub ExtractForIndex()
Dim vKeyWords As Variant
Dim rCell As Range
Dim rFound As Range
Dim i As Long
Dim sFoundAddr As String

vKeyWords = Array("Chevy", "Buick", "Cadillac")
With Columns(1).Cells
For i = 0 To UBound(vKeyWords)
Set rFound = .Find( _
What:=vKeyWords(i), _
LookIn:=xlValues, _
LookAt:=xlPart, _
MatchCase:=False)
If Not rFound Is Nothing Then
sFoundAddr = rFound.Address
Do
rFound.Offset(0, 1).Value = vKeyWords(i)
Set rFound = .FindNext(After:=rFound)
Loop Until rFound.Address = sFoundAddr
End If
Next i
End With
End Sub

Note: This assumes only one keyword per cell. If multiple keywords
are in a cell, only the last will be listed. If that's the case and
you need assistance in modifying the macro, post back.



In article ,
"Brad" wrote:

How would you go about this? Column of cells of text. I want to seach

each
cell for a list of words and, if a word is found, put a value in a cell.
Example. If text contains any of the words Chevy, Buick, Caddilac, i'd

like
to out that word in an ajacent cell for indexing purposes. The list of

words
will be pretty long so nested if's are not a good approach. Thanks for

any
suggestions.



---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.548 / Virus Database: 341 - Release Date: 05/12/2003