ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Finding a cell (https://www.excelbanter.com/excel-programming/319905-finding-cell.html)

Himszy

Finding a cell
 
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



Tom Ogilvy

Finding a cell
 
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

--
Regards,
Tom Ogilvy


"Himszy" wrote in message
.. .
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





Himszy

Finding a cell
 
Thanks Tom


"Tom Ogilvy" wrote in message
...
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

--
Regards,
Tom Ogilvy


"Himszy" wrote in message
.. .
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







Himszy

Finding a cell
 
Tom is there a way of removing the $ signs?

"Himszy" wrote in message
...
Thanks Tom


"Tom Ogilvy" wrote in message
...
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

--
Regards,
Tom Ogilvy


"Himszy" wrote in message
.. .
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









Tom Ogilvy

Finding a cell
 
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

--
Regards,
Tom Ogilvy


"Himszy" wrote in message
...
Tom is there a way of removing the $ signs?

"Himszy" wrote in message
...
Thanks Tom


"Tom Ogilvy" wrote in message
...
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

--
Regards,
Tom Ogilvy


"Himszy" wrote in message
.. .
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












All times are GMT +1. The time now is 02:52 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com