View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.programming
Sandeman[_3_] Sandeman[_3_] is offline
external usenet poster
 
Posts: 1
Default Macro idendifying keywords


Super. How you and others acquire this expertise, I'll never know.
This is working very well. Now I've run into an unforeseen issue. If
in the description I search for the word "Italian," the word Italy is
placed in a cell to the right. If I also look for the word "Italy,"
the word Italy is then placed two cells to the right. That means
"Italy" has been listed twice. Would it be possible to add code that
states if "Italy" has been found once, skip the next variations of the
word "Italy" and move on to the next group (e.g. basketball)? There
should be come work around perhaps?

Tom Ogilvy Wrote:
As I said, it my contain typos - in this case, it contained two. Here
is a
tested version (based on your description).

Sub ProcessWords()
Dim v As Variant, v1 As Variant
Dim rng As Range, cell As Range
Dim i As Long, col As Long
v = Array("Italian", "BasketBall")
v1 = Array("Italy", "BasketBall")
Set rng = Range(Cells(1, 3), _
Cells(Rows.Count, 3).End(xlUp))
For Each cell In rng
col = 4
For i = LBound(v) To UBound(v)
If InStr(1, cell.Value, v(i), _
vbTextCompare) Then
Cells(cell.Row, col).Value = v1(i)
col = col + 1
End If
Next
Next
End Sub

"Sandeman" wrote:


Very cool Tom. Thank you. The If, Then line is not working out and

I'm
not sure what's wrong with it. Any ideas?




--
Sandeman
------------------------------------------------------------------------
Sandeman's Profile: http://www.excelforum.com/member.php...o&userid=32440
View this thread: http://www.excelforum.com/showthread...hreadid=522153