View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.programming
Ron Rosenfeld Ron Rosenfeld is offline
external usenet poster
 
Posts: 5,651
Default Optional Arguements for Functions

On Tue, 3 Feb 2004 21:17:19 -0600, ExcelMonkey
wrote:

I want to build a function which takes two optional arguements. If Y
and Z are note provided, I would like to make them equal to 1. How do
I state this within the function? They way I have it below will force
them to 1 regardless.

Private Function New(X As Double, Option Y As Double, Optional Z As
Double)

'if Y and Z are not provided then force them to value of 1
Y = 1.0
Z = 1.0

New = X*Y*Z



Try:

Function Nw(X As Double, Optional Y As Double = 1, Optional Z As Double = 1)

Nw = X * Y * Z

End Function

--ron