View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
sivrik[_3_] sivrik[_3_] is offline
external usenet poster
 
Posts: 1
Default Searching for a words in a column from a list of words.

Hi Scott,

This might help you get started at least. I'm not sure
what you want to do when you find a match so now it just
displays a message box with the row number of the match.
Here goes:

Add a commandbutton to the sheet and put this code in its
click event:

Dim astrList(5) As String
Dim lngUpperBound As Long
Dim strText As String
Dim lngIndex As Long
Dim lngRow As Long

'set the upperbound of the array
'(number of words it'll contain)
lngUpperBound = 5

'add words to the array
astrList(0) = "boB"
astrList(1) = "George"
astrList(2) = "woRd"
astrList(3) = "match?"
astrList(4) = "YES"

'look for any matches in col1
For lngRow = 10 To 100
strText = UCase(ActiveSheet.Cells(lngRow, 1).Value)
For lngIndex = 0 To lngUpperBound - 1
If UCase(astrList(lngIndex)) = strText Then
'match - do what you want here
MsgBox "Found a word in row " & lngRow
End If
Next
Next

HTH,
sivrik.

-----Original Message-----
Hi,

Not sure if this is possible, but hope someone can help.

I'm trying to create a macro that will look at column A

from row 10 to 100
for certain words. These words would be in a list,

i.e. "Word One", "Word
Two", "Word Three", "Word Four", "Word five", "Word six",

but also this is
not case sensitive, so it would look at the text if it

was upper or lower
case. Could these words be in an array or not, I'm not

very good at writing
macros so please bare with me.
Then the cell that contains this word would make the same

row but column D
active, if you know what I mean.

Hope someone can help,
Thanks
Best regards,
Scott


.