ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Range Find (https://www.excelbanter.com/excel-programming/412331-range-find.html)

greg

Range Find
 
I am using the Find method of Range.
Do you have to find whole strings of the cell?
I am sending in a filename. But my cell contains full path. and it is not
finding the cell.
For example:

Cell:
C:\foo\foo\foo\myfile.doc

and my code is this:
Set objFind = objSheet.Range(strRange).Find(what:=Trim$("myfile. doc"),
LookIn:= _
xlFormulas, lookat:=xlWhole, SearchOrder:=xlByColumns,
SearchDirection:= _
xlNext, MatchCase:=False)

Do you need to find full strings?



Ron de Bruin

Range Find
 
See the VBA help

You can use
xlPart

--

Regards Ron de Bruin
http://www.rondebruin.nl/tips.htm


"greg" wrote in message ...
I am using the Find method of Range.
Do you have to find whole strings of the cell?
I am sending in a filename. But my cell contains full path. and it is not
finding the cell.
For example:

Cell:
C:\foo\foo\foo\myfile.doc

and my code is this:
Set objFind = objSheet.Range(strRange).Find(what:=Trim$("myfile. doc"),
LookIn:= _
xlFormulas, lookat:=xlWhole, SearchOrder:=xlByColumns,
SearchDirection:= _
xlNext, MatchCase:=False)

Do you need to find full strings?



JE McGimpsey

Range Find
 
Take a look in VBA Help for the Find function. Specifically, the
"LookAt" argument...

In article ,
"greg" wrote:

I am using the Find method of Range.
Do you have to find whole strings of the cell?
I am sending in a filename. But my cell contains full path. and it is not
finding the cell.
For example:

Cell:
C:\foo\foo\foo\myfile.doc

and my code is this:
Set objFind = objSheet.Range(strRange).Find(what:=Trim$("myfile. doc"),
LookIn:= _
xlFormulas, lookat:=xlWhole, SearchOrder:=xlByColumns,
SearchDirection:= _
xlNext, MatchCase:=False)

Do you need to find full strings?


Per Jessen

Range Find
 
Hi
Substitute

LookAt:=xlWhole

with

LookAt:=xlPart

Regards,
Per

"greg" skrev i meddelelsen
...
I am using the Find method of Range.
Do you have to find whole strings of the cell?
I am sending in a filename. But my cell contains full path. and it is
not finding the cell.
For example:

Cell:
C:\foo\foo\foo\myfile.doc

and my code is this:
Set objFind = objSheet.Range(strRange).Find(what:=Trim$("myfile. doc"),
LookIn:= _
xlFormulas, lookat:=xlWhole, SearchOrder:=xlByColumns,
SearchDirection:= _
xlNext, MatchCase:=False)

Do you need to find full strings?





All times are GMT +1. The time now is 03:12 AM.

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