Dim result1 As Range, result2 As Range, finalresult As Range
With Worksheets(1).Range("a1:C500")
Set c = .Find("aaa", LookIn:=xlValues)
firstAddress = c.Address
If Not c Is Nothing Then
Set result1 = c
Do
Set result1 = Union(result1, c)
Set c = .FindNext(c)
Loop While Not c Is Nothing And c.Address <> firstAddress
End If
End With
With Worksheets(1).Range("a1:C500")
Set c = .Find("bbb", LookIn:=xlValues)
firstAddress = c.Address
If Not c Is Nothing Then
Set result2 = c
Do
Set result2 = Union(result2, c)
Set c = .FindNext(c)
Loop While Not c Is Nothing And c.Address <> firstAddress
End If
End With
Set finalresult = Intersect(result1, result2)
msgbox(finalresult.Address)作者: webbliu 時間: 2011-1-26 02:00