View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Tom Ogilvy Tom Ogilvy is offline
external usenet poster
 
Posts: 27,285
Default User Defined Function for Wind Chill

The normal way it to let excel handle it for you

Function WindChill(WindSpeed_MPH as Double, Temp_F° as Double)

Excel would then return #Value! if the values were non numeric and would
notify the user during entry if an argument were missing. This is the way
other functions work and it would be best to mimic their behavior.

If you insist on your approach, you would need to use a paramarray so you
can have avariable number of arguments, then loop through it.

If you want the optional argument with a default value, then that is
explained as well. Look at the Function Statement in Excel VBA Help.


highlight the word Function in your function and hit F1. Choose VBA and you
should see the help.

--
Regards,
Tom Ogilvy




"Carroll" wrote in message
oups.com...
Hello,

I was working on a user-defined function for the Wind Chill Index.
Here is what I came up with so far:

Function WindChill(WindSpeed_MPH, Temp_F°)

WindChill = Format((91.4 - (0.474677 - 0.020425 * WindSpeed_MPH +
0.303107 * WindSpeed_MPH ^ 0.5) * (91.4 - Temp_F°)), "0.0°")

End Function

I got the formula off the internet. I have seen where you can also
have a third parameter to define whether the temperature is Fahrenheit
or Celsius, but I won't worry about that as I never use Celsius, but
I'm sure that could be done as well. If I were to add it, I would make
it that if the third parameter was not used, then it would assume that
you were wanting to use Fahrenheit.

I was wanting to improve it somewhat. For instance, to put a message
right in the cell if two parameters haven't been provided, one or the
other was null, or not numeric. Since parameters can come from a cell
feeding the parameter, or put directly in the cell with the function, I
wasn't sure what was the best way to handle that was. Any ideas? I
wasn't able to get isblank(), etc. to work.

Also, when the function parameter wizard (I think that's the term) is
used, is there any way for me to provide help for that box?

Thanks,

Carroll Rinehart