ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Searching for specific text (https://www.excelbanter.com/excel-programming/303843-searching-specific-text.html)

simoncohen[_5_]

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

Thank

--
Message posted from http://www.ExcelForum.com


Frank Kabel

Searching for specific text
 
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

--
Regards
Frank Kabel
Frankfurt, Germany


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

Thanks


---
Message posted from http://www.ExcelForum.com/


Don Guillett[_4_]

Searching for specific text
 
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
--
Don Guillett
SalesAid Software

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

Thanks


---
Message posted from
http://www.ExcelForum.com/




Don Guillett[_4_]

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

--
Don Guillett
SalesAid Software

"Don Guillett" wrote in message
...
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
--
Don Guillett
SalesAid Software

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

Thanks


---
Message posted from
http://www.ExcelForum.com/







All times are GMT +1. The time now is 12:25 PM.

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