Logo 
Search:

MS Office Answers

Ask Question   UnAnswered
Home » Forum » MS Office       RSS Feeds
  Question Asked By: Vivek Patel   on Oct 20 In MS Office Category.

  
Question Answered By: Viheke Fischer   on Oct 20

I like using the "Match" function since it can be set to find an exact match.
I believe the "Find" function requires the LookUp list ot be sorted ascending to
work right & may not guarantee an exact match.
Not sure if I follow your flow of events, but give this a try (I havent tested
it fully):

Sub testLookUpName2()
vGetTotalRowsInData = Range("A1").CurrentRegion.Rows.Count
For vRowNumber = 2 To vGetTotalRowsInData
vNameToLookUp = Sheets("Sheet1").Range("A" & vRowNumber).Value
If Not (IsEmpty(vNameToLookUp)) Then

If IsError(vRowMatch = WorksheetFunction.Match(vNameToLookUp,
Sheets("Sheet2").Range("D:D"), 0)) Then
'skip: not found
Else
vRowMatch = WorksheetFunction.Match(vNameToLookUp,
Sheets("Sheet2").Range("D:D"), 0)
vActualEmployeeName = Sheets("Sheet2").Range("E" & vRowMatch).Value
Sheets("Sheet1").Range("A" & vRowNumber).Offset(0, 26).Value = vNewEmployeeName
End If

End If
Next vRowNumber

End Sub

Share: 

 

This Question has 12 more answer(s). View Complete Question Thread

 
Didn't find what you were looking for? Find more on How to make WorksheetFunction.MATCH OR .VLOOKUP work? Or get search suggestion and latest updates.


Tagged: