PDA

View Full Version : vlookup udf



lior03
05-10-2006, 09:15 AM
hello
i have a table looking like this:
namepricemoshe20ron30gila40ruth320

i am trying to use it so by inserting a name i will get the price and then multply it by a quantity i specified.
my function look like this:

Function windbag(name As String, quantity As Integer)
Dim Table As Range
Dim Price As Integer
Set Table = Sheets("product").Range("e5:f9")
Price = Application.WorksheetFunction.VLookup(Price, Table, 2)
windbag = quantity * Price
End Function

what went wrong?
thanks

lior03
05-10-2006, 09:16 AM
namepricemoshe20ron30gila40ruth320

lior03
05-10-2006, 09:18 AM
namepricemoshe20ron30gila40ruth320

geekgirlau
05-10-2006, 07:59 PM
You can't use Price as the lookup value, because it's empty. At the moment you are asking Excel to find nothing in the Table.


Price = Application.WorksheetFunction.VLookup(Price, Table, 2)

mdmackillop
05-11-2006, 05:47 AM
Price may not always be an integer. Better declared as long.