Searching for specific text

  • Thread starter Thread starter simoncohen
  • Start date Start date
S

simoncohen

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

Thank
 
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
 
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
 
or even shorter
Range("d7:d12").Find("xyz", lookat:=xlPart).Select

--
Don Guillett
SalesAid Software
(e-mail address removed)
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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top