View Single Post
  #6   Report Post  
Posted to microsoft.public.excel.newusers
LurfysMa LurfysMa is offline
external usenet poster
 
Posts: 61
Default Help defining a user-defined function

On Sat, 9 Jun 2007 22:09:34 -0300, "Bernard Liengme"
wrote:

Would you please comment on the use of ByVal
I understand what it means but is it required/recommended?
best wishes


ByVal = "by value", which means that the "value" of the variable is
passed to the function as opposed to ByRef, which = "by reference",
which means that a reference (pointer) to the source is passed.

ByRef means that the function is working with the caller's variables,
which is usually considered bad programming. If VB6, ByRef is the
default, which is a mistake.

In VBA (for Excel), if the caller is the spreadsheet, I'm not sure it
makes much difference as I don't think ByRef will cause the source
cell to change.

I always code ByVal because I can never rememeber the defaults.


--