Variable number of arguments

  • Thread starter Thread starter mcescher
  • Start date Start date
M

mcescher

Hi All,
I'm sure this has been addressed before, but I couldn't come up with
the correct search terms to find it.

It seems that I heard one time that there is a way to define a
function with a variable number of arguments. Is this possible? What
is the construct?

Thanks for your time,
Chris M.
 
mcescher said:
I'm sure this has been addressed before, but I couldn't come up with
the correct search terms to find it.

It seems that I heard one time that there is a way to define a
function with a variable number of arguments. Is this possible? What
is the construct?


Decalare your procedure's last argument with the ParamArray
keyword. See Function Statement in VBA Help

E.g.

Public Function MySum(ParamArray varList())
For Each X in varList
MySum = MySum + x
Next x
End Function
 
mcescher said:
I'm sure this has been addressed before, but I couldn't come up with
the correct search terms to find it.

It seems that I heard one time that there is a way to define a
function with a variable number of arguments. Is this possible? What
is the construct?


Decalare your procedure's last argument with the ParamArray
keyword. See Function Statement in VBA Help

E.g.

Public Function MySum(ParamArray varList())
For Each X in varList
MySum = MySum + x
Next x
End Function
 
Decalare your procedure's last argument with the ParamArray
keyword.  See Function Statement in VBA Help

E.g.

Public Function MySum(ParamArray varList())
        For Each X in varList
                MySum = MySum + x
        Next x
End Function

Thanks to all who replied. That was just what I was looking for.

Chris M.
 
Decalare your procedure's last argument with the ParamArray
keyword.  See Function Statement in VBA Help

E.g.

Public Function MySum(ParamArray varList())
        For Each X in varList
                MySum = MySum + x
        Next x
End Function

Thanks to all who replied. That was just what I was looking for.

Chris M.
 
Back
Top