Searching for specific text

S

simoncohen

I need to loop down a range and stop when a cell contains the text "xyz
somewhere within a cell.

Thank
 
F

Frank Kabel

Hi
one way: try something like
sub foo()
dim rng as range
dim cell as range
set rng = activesheet.range("A1:A100")
for each cell in rng
if instr (cell.value,"xyz") then
msgbox cell.address
cell.select
exit sub
end if
next
end sub
 
D

Don Guillett

try this
Sub findxyz()
x = Range("d7:d12").Find("xyz", lookat:=xlPart).Address
MsgBox x
End Sub

sub gotoxyz
Range(Range("d7:d12").Find("xyz", lookat:=xlPart).Address).Select
end sub
 
D

Don Guillett

or even shorter
Range("d7:d12").Find("xyz", lookat:=xlPart).Select

--
Don Guillett
SalesAid Software
[email protected]
Don Guillett said:
try this
Sub findxyz()
x = Range("d7:d12").Find("xyz", lookat:=xlPart).Address
MsgBox x
End Sub

sub gotoxyz
Range(Range("d7:d12").Find("xyz", lookat:=xlPart).Address).Select
end sub
 
Top