Vlookup function
"Antonis" wrote in message
...
Hello,
I have the following code
Function Price(Code, Table)
Price = WorksheetFunction.VLookup(Code, Table, 18, False)
End Function
am using this function in order to get from the 18th column the price of a
specific product with Code. The codes of the different products are listed
in
the 1st column. On the 1st column the codes of the different products can
be
repeated many times.
With this vba code I am using I can get the price of the first listed
product. But I want to get the last.
Can someone please help me solve this problem?
Thank you in advance.
In a simple way:
------------------------------
Function Price(Code, Table)
Dim i As Long
For i = Table.Rows.Count To 1 Step -1
If Table(i, 1) = Code Then
Price = Table(i, 18)
Exit Function
End If
Next
End Function
-----------------------------
Ciao
Bruno
|