View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Don Guillett Excel MVP Don Guillett Excel MVP is offline
external usenet poster
 
Posts: 168
Default How to write a VBA function which returns an integer

On Aug 13, 7:51*am, Andrew wrote:
Hello,
I could use some help on the syntax of writing a function file in VBA
which takes two integers as input arguments and returns one integer.
Let's say my function was called TEST, and TEST took the average of
two integers.

It seems that the code should look like this:

AVG=TEST(2,8)

But all function files that i have seen in VBA use Call to execute the
function. *Can someone help me out with this?

thanks
Andy


Function mavg(x, y)
mavg = (x + y) / 2
End Function
But why not just use =avg