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 Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Vfp Automating Excel Find()

Status
Not open for further replies.

JERRYFOOTE

Programmer
Aug 5, 2002
8
US
Using VFP9 and Excel 2003
Everything was going fine and then I added barcods in the format “0001”,”0002” ect
Now the find command locates the first record with “0001” so a barcode “8991202000123” is found
I understand that there are aruguments to the find command such as wholewords but I cannot figure out how to code for that.

I hope you can see my problem and explain how to correct the syntax to find wholewords

Thanks Jerry


Select UPINVENTORY
Scan
Target=Alltrim(UPINVENTORY.BARCODE)
Found=.F.
Try
rowrange="B1:B"+Transform(Thisform.MAXROW.Value)
=====================================================================
Found=Thisform.oExcel.Range(rowrange).Find(Target).Select && this is line I need to fix
=====================================================================
Endtry
If Found
LAST_ADDRESS = Thisform.oExcel.ActiveCell.Address
LAST_ROW = Thisform.oExcel.ActiveCell.Row
Column=Alltrim(UPINVENTORY.colname)
NEW_ADDRESS="$"+Transform(Column)+"$"+Transform(LAST_ROW)
Thisform.oExcel.Range(NEW_ADDRESS).NumberFormat = "0.00"
If Thisform.upinventry.Value=2
newvalue=Thisform.oExcel.Range(NEW_ADDRESS).Value
If ! Isnull(newvalue)
Thisform.oExcel.Range(NEW_ADDRESS).Value =newvalue+UPINVENTORY.quanity
Else
Thisform.oExcel.Range(NEW_ADDRESS).Value = UPINVENTORY.quanity
Endif
Else
Thisform.oExcel.Range(NEW_ADDRESS).Value = UPINVENTORY.quanity
Endif
Else
Endif
Endscan
 
Don't know what version of Excel you're using, but the help file for XL2007 says the prototype for Range.Find() says this:

Find(What, [After], [LookIn], [LookAt], [SearchOrder], [SearchDirection As XlSearchDirection = xlNext], [MatchCase], [MatchByte], [SearchFormat])

The 4th parameter controls what Excel "looks at". So I think you want this:

xlPart=2
Found=Thisform.oExcel.Range(rowrange).Find(Target,,,xlPart).Select
 
Oops. You said Excel 2003. See what the VBA help file says for range.find()'s syntax.
 
Well that was a very big help.. It seem xlPart had to be 1.
That works and finds the exact target.
Thanks a lot, a whole bunch.

Thanks again
Jerry
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top