A Microsoft Office (Excel, Word) forum. OfficeFrustration

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » OfficeFrustration forum » Microsoft Excel » Worksheet Functions
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

Newbe help - VBA function



 
 
Thread Tools Display Modes
  #1  
Old April 21st, 2004, 01:08 AM
Kristen
external usenet poster
 
Posts: n/a
Default Newbe help - VBA function

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
  #2  
Old April 21st, 2004, 02:24 AM
Bob Umlas
external usenet poster
 
Posts: n/a
Default Newbe help - VBA function

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

"Kristen" wrote in message
om...
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



  #3  
Old April 21st, 2004, 10:30 PM
Kristen
external usenet poster
 
Posts: n/a
Default Newbe help - VBA function

Thankyou Bob

I'll put it in my function.

Thankyou
Kristen

"Bob Umlas" wrote in message ...
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

"Kristen" wrote in message
om...
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

 




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump


All times are GMT +1. The time now is 04:32 PM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.