• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

vba find Whole field

mdavid

Member
Hi,
Have the following:
Code:
If SpeciesID < 600 Then
        Set found = Sheets("Sheet2").Range("C2:C" & totArabic).Find(what:=SpeciesID) 'finds a match
    Else
        Set found = Sheets("Sheet2").Range("B2:B" & totArabic).Find(what:=SpeciesID) 'finds a match
    End If
Problem:
If SpeciesID = 11 .Find(what:=SpeciesID) returns Cell with value 110
How do I ensure the search returns a whole field value?
Thanks
 
Try this:

Code:
If SpeciesID < 600 Then
        Set found = Sheets("Sheet2").Range("C2:C" & totArabic).Find(what:=SpeciesID, LookIn:=xlvalues, LookAt:=xlWhole) 'finds a match in Col C
    Else
        Set found = Sheets("Sheet2").Range("B2:B" & totArabic).Find(what:=SpeciesID, LookIn:=xlvalues, LookAt:=xlWhole) 'finds a match in Col B
    End If
 
Back
Top