Here is the Code with less words but matches ur speed:-
![]()
Function NthMatch(ByVal Lvalue As Variant, Lrange As Variant, Mnum As Variant) Mstr = "|" & Join(Application.Transpose(Lrange), "|") Lvalue = "|" & Lvalue Start = 0 For c = 1 To Mnum Start = InStr(Start + 1, Mstr, Lvalue) If Start = 0 Then NthMatch = "#N/A": GoTo 0 '<--- This the line which I have included to leave loop. Next Temp = Left(Mstr, Start) NthMatch = Len(Temp) - Len(Replace(Temp, "|", "")) '<-- Calculating Row No. 0 End Function
Bookmarks