PDA

View Full Version : How to have excel show the input variables in a custom made functions?



dtms1
10-14-2010, 06:44 PM
Hi everyone

I just made a function in vba and so far everything is good and working. The only problem is when I go to excel and type my function "=tempus(" excel doesn't show me the input variables I have to have.

In the already built excel functions when you type the function and right after the open parenthesis is typed it displays the needed input variables.

Is there a way to do that with custom built functions from vba?

thanks for your time

if it matters here is my working code
Function tempUS(elev)
''''''Temperature
'In Rankine
'Function of Elevation

atmos = Application.Match(elev, Array(0, 36100, 65600, 105000), 1)
'Sea Level=0 Troposphere= 0-36100 Tropopause= 36100-65600 Stratosphere= 65600-105,000
temp1 = Application.Choose(atmos, 518.67, 389.93, 391.57)
'Start of Troposphere= 518.67 Start of Tropopause= 389.93 Start of Stratosphere= 391.57
n = Application.Choose(atmos, 1.235, 1, 0.974)
'n At Troposphere = 1.235 n at tropopause= 1 n At Stratosphere= .974
z1 = Application.Choose(atmos, 0, 36100, 65600)
'Sea Level=0 Troposphere= 0-36100 Tropopause= 36100-65600 Stratosphere= 65600-105,000
press1 = Application.Choose(atmos, 14.696, 3.276, 0.79261)
'Start of Troposphere=14.696 Start of Tropopause=3.276 Start of Stratosphere=.79261
Density1 = Application.Choose(atmos, 0.002377, 0.0007044, 0.00017)
'Start of Troposphere= .002377 Start of Tropopause= .0007044 Start of Stratosphere= .00017

tempUS = temp1 * (1 - ((n - 1) / n) * (g / (Rair * temp1)) * (elev - z1))

Kenneth Hobs
10-14-2010, 07:19 PM
Welcome to the forum!

An ExecuteExcel4Macro method is best. There are better examples but here is one to get you started. http://www.bettersolutions.com/excel/EIK284/YN723710331.htm

Jan offers an excellent example that the link above will lead you to.
http://www.jkp-ads.com/articles/RegisterUDF00.asp