VBA If Statements

November 13, 2011 at 12:31:04
Specs: Windows 7
How do I write a VBA function procedure called bigger that takes two inputs and outputs the bigger number. If the two numbers are equal, it would output one of the numbers.

So far I have come up with this coding, but im not sure why it does not work

Function bigger(A As Double, B As Double)
bigger = A
If A < B Then B
Else: A
End If
End Function

Any help would be appreciated, Thank You

See More: VBA If Statements

November 13, 2011 at 14:06:58
Without testing anything since I'm not in front of Excel at the moment, I'll take a guess...

You are setting the function equal to A before you do any testing of A and B.

I would try something like this:

Function bigger(A as Double, B as Double)
  If A > B Then bigger = A Else bigger = B 
End Function

Click Here Before Posting Data or VBA Code ---> How To Post Data or Code.

Report •

November 13, 2011 at 16:13:35
Thank you for your help

Report •
Related Solutions

Ask Question