View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Barb Reinhardt Barb Reinhardt is offline
external usenet poster
 
Posts: 3,355
Default loop through matches

Here's a starting point. It's crude and I'd probably add some error
checking, but it should work. If you want something returned, this can be
modified to be a function, but I'd need to know what you want returned.

Sub Macro1()
'
Dim aWS As Worksheet

Dim myRange As Range
Dim r As Range

Set aWS = Worksheets("Sheet1") '<~~change here
Set myRange = aWS.Range("A1:A100") '<~~~change here
For Each r In myRange
If LCase(r.Value) = "mystring" Then '<~~~change here
MsgBox ("Match found at " & r.Address)
End If
Next r

End Sub
--
HTH,
Barb Reinhardt



"geebee" wrote:

hi,

i have a formula that is lke MATCH(B2)...

the only problem is that there can be more than one occurence of the item we
are matching in the column. so i would like to know how i can write code to
loop through to get the matches if there is more than one match.

thanks in advance,
geebee