Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Find Method in Excel

Status
Not open for further replies.

mo2783

Programmer
Nov 16, 2003
68
GB
Hello All

I am having some problems with a find method I am using in excel VBA.

I have many lines in this file which begin with - “TEXT /OUTFIL” and the other text.

I need to find the “Part Name” from this string within this file

From this file I am using the following find method

TEXT/OUTFIL,'* Part Name : Front door inner LH *'

The following code is suppose to find the part Name from the above line of text. But I am getting an error string isn’t found.

Code:
Set FoundCell = LastCell.Find(What:=strFindItem, After:=ActiveCell, _
                        LookIn:=xlValues, LookAt:=xlPart, SearchOrder:=xlByRows, _
                        MatchCase:=False)

Can anyone help?

Thanks

Mo
 



Hi,

Exactly what value is in strFindItem?

What is the RANGE of LastCell? If this is a single cell, you will probably find NOTHING. This range must include any value you are trying to find, like Cells.

Also loose the ActiveCell and, instead, use a cell range reference, like the last find.



Skip,

[glasses]Just traded in my old subtlety...
for a NUANCE![tongue]
 
Hi

Thanks for the help but i have work out why it wouldnt work as the workbook containing "Part Name" wasnt made active.

Mo
 



That workbook does not need to be the activeworkbook, as long as all your range references include reference to THAT WORKBOOK and THAT SHEET that you are trying to find "Part Name" on, like...
Code:
Dim wsOther as Worksheet

Set wsOther = YourOtherWorkbookObject.YourSheetObject 

Set FoundCell = [b]wsOther.Cells[/b].Find(What:=strFindItem, After:=[b]wsOther.[A1][/b], _
                        LookIn:=xlValues, LookAt:=xlPart, SearchOrder:=xlByRows, _
                        MatchCase:=False)


Skip,

[glasses]Just traded in my old subtlety...
for a NUANCE![tongue]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top