problem in VBA module

G

Guest

Dear friends i have a problem with Vba moudle let me give u the detail about
it
suppose i have a sheet where i have given the label to various column like
column a1 = item
columnb1=price
columnc1=tax
so i have defined a module for it.

Public Function price(item)
If (item = "oranges") Then
price = 100
tax = 0.2
ElseIf (item = "Mango") Then
price = 200
tax = 0.5
End If

End Function

so when i return to my Excel sheet

item tax price
apple =price(a2) "where a2 equal to apple
under item column"

it give me the price 100 for apple but it don't give me the tax 0.2 so i
need it too .
plz help me. how to make it correct.
thanks .
i am looking forward to someone to help me .
 
A

Alex Dybenko

function can return only one value.
you need to make also Tax functon like:

Public Function tax(item)
If (item = "oranges") Then
tax = 0.2
ElseIf (item = "Mango") Then
tax = 0.5
End If
End Function

better aproach could be if you make a table with items/price/tax and lookup
corresponding values.
you can try to ask at excel group
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top