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 FunctionAny help would be appreciated, Thank You

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.

Thank you for your help

Ask Your Question

Weekly Poll

Do you think Microsoft can save the Surface Book lineup?

Discuss in The Lounge

Poll History