Hi Folks,
Yesterday I posted following thread in this section ..
http://www.excelforum.com/tips-and-t...ift-enter.html
The thread was about using "Sumproduct as an alternative to array formulas.."
I was very happy that I made something like this..
but our Sir Mr. XOR opened my eyes and explain me why my formula was not that much fast as array function.. and was more intensive resource wise as well...
Then I started think about another alternative..
Actually I had, before posting the above thread, made an UDF ie NthMatch.. to return the Row No. of the Nth Match of a value in the array..
It is an improvement over Match function.. as Match function only returns row No. of the first Match...
when I got the solution.. what I saw that The NthMatch alternative was short(lenght wise) of the Sumproduct and Array alternatives..
So that is what I wanted to share with you all..
Have a visit at the link below.. and let me know whether there are any chances of improvement..
http://excel-buzz.blogspot.in/2014/0...-to-array.html
Here is the code for NthMatch(Lookup_value, Lookup_Range, Match No.)
Function NthMatch(ByVal Lvalue As Variant, ByVal Lrange As Variant, Mnum As Variant) As Integer
'*************Developed by Vikas Gautam ****************
'*************www.Excel-buzz.blogspot.com***************
Dim Arr()
ReDim Arr(0)
r = 0
If IsArray(Lrange) Then
For Each cell In Lrange
c = c + 1 'c counts row no. to be checked
If cell = Lvalue Then
ReDim Preserve Arr(r)
Arr(r) = c 'assigning row no. of the match row to the Arr
r = r + 1
End If
Next
Else
If Lvalue = Lrange Then Arr(0) = 1 'if the Lrange is a single value ....
End If
NthMatch = Arr(Mnum - 1)
End Function
View post #9 for better solution given by KVS
Regards,
Vikas Gautam
Bookmarks