Logo 
Search:

MS Office Answers

Ask Question   UnAnswered
Home » Forum » MS Office       RSS Feeds
  Question Asked By: Diane Collins   on Aug 13 In MS Office Category.

  
Question Answered By: William Evans   on Aug 13

You just need to set the Find function LookAt
parameter to xlWhole. Here is a revised
index_on_pricing function:

Function index_on_pricing(id As String) As Long
Dim Rng As Range
Set Rng = Application.Workbooks("catalog
PRICING.xls").Sheets(1).Range("a1:a30000").Find(What:=id,
LookAt:=xlWhole)
If Rng Is Nothing Then
index_on_pricing = -1
Else
index_on_pricing = Rng.Row
End If
Set Rng = Nothing
End Function

This only executes the Find once, instead of
potentially twice per your original code. It also
defines the return  value, as every function should.

Share: 

 
 
Didn't find what you were looking for? Find more on Need a Quick Fix for my script Or get search suggestion and latest updates.


Tagged: