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


Looks as if I need to make some changes to the macro structure. What I
need the following macro to do is the following. If the macro looks at
a description and identifies the word "Italian", it places the word
"Italy" in a cell three columns over (column is "nation"). If it also
identifies the word "basketball," it places the word "Basketball" in a
cell four columns over (column is for "sport"). There are multiple
identifiers I want to use, but I can set that up as long as I get the
gist on how to edit the following to do this. Thanks!

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
------------------------------------------------------------------------
Sandeman's Profile: http://www.excelforum.com/member.php...o&userid=32440
View this thread: http://www.excelforum.com/showthread...hreadid=522153