Newbe help - VBA function

K

Kristen

Newbe needs help

I'm creating a function for Excel.
I want the function to operate two different ways depending on the
contents of a sell.

Like
If cell A1 (AB in VBA function ) is A then Va * Vb
If cell A1 (AB) is B then Va * Vc


In Excel IF function terms I'm wanting to:

=IF(AB = "A",Va*Vb,IF(AB = "B",Va*Vc,"-"))

So what should my function be in VBA:
Function test(AB, Va, Vb, Vc)
?? where to from here

Thankyou for your help
Kristen
 
B

Bob Umlas

Function test(AB,Va,Vb,Vc)
IF AB="A" then
test=Va * Vb
ElseIf AB = "B" then
test = Va * Vc
Else
test = "-"
End If
End Function

Bob Umlas
Excel MVP
 

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