Hi KVS Sir,
There is a problem with your code (When I removed last 500 rows of data from reference),
Pl have a look at Row 670 for explanation.
I acknowledge the fact that you have the speed a lot by removing unnecessary steps in the code.
So, I believe the Final version should be.
Function NthMatch(ByVal Lvalue As Variant, Lrange As Variant, Mnum As Variant)
Mstr = "|" & Join(Application.Transpose(Lrange), "|") & "|"
Start = 1
For c = 1 To Mnum
Start = InStr(Start + 1, Mstr, Lvalue)
If Start = 0 Then End '<--- This the line which I have included to leave loop.
Next
Temp = Left(Mstr, Start)
NthMatch = Len(Temp) - Len(Replace(Temp, "|", "")) '<-- Calculating Row No.
End Function
Bookmarks