Finding a cell

  • Thread starter Thread starter Himszy
  • Start date Start date
H

Himszy

If I wish to find a cell containing some text, how do I find it and then
place the grid reference in a variable.

Thanks Michael
 
the "grid reference" is in the variable rng

Dim rng as Range
sStr = "text"
set rng = Cells.find(what:=sStr, _
LookIn:=xlValues, LookAt:=xlPart)
if not rng is nothing then
msgbox rng.Address
else
msgbox sStr & " Not Found!"
End if
 
Thanks Tom


Tom Ogilvy said:
the "grid reference" is in the variable rng

Dim rng as Range
sStr = "text"
set rng = Cells.find(what:=sStr, _
LookIn:=xlValues, LookAt:=xlPart)
if not rng is nothing then
msgbox rng.Address
else
msgbox sStr & " Not Found!"
End if
 
Dim rng as Range
sStr = "text"
set rng = Cells.find(what:=sStr, _
LookIn:=xlValues, LookAt:=xlPart)
if not rng is nothing then
msgbox rng.Address(0,0)
else
msgbox sStr & " Not Found!"
End if
 

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