Using GAMMADIST in VBA

  • Thread starter Thread starter DonA
  • Start date Start date
D

DonA

I'm having trouble with the GAMMADIST function in my macro. When
running, I get an error that the function is not defined. The
function parameters of X, alpha and beta I know are not the problem
since they work in a simple spreadsheet expression. Do I need to
acivate a reference? Thanks in advance.
 
You can use the Application.WorkSheetFunction object to execute
worksheet function.

Dim A as Double

A = Application.WorksheetFunction.*GammaDist(number1, number2, number3
number4)*

cells(1,1).value =
 
The asterisks were presumably given for emphasis, since they are not
acceptable syntax.

Older versions of Excel do not recognize the WorksheetFunction keyword.
For those you would use Application.GammaDist(), which will also work
in newer versions of Excel. The advantage of using the
WorksheetFunction keyword is that it will pull up a list of available
Excel worksheet functions (many, but not all of Excel's worksheet
functions can be called in this way). Using both keywords
(Application.WorksheetFunction.) together will certainly work, but is
probably overkill.

Jerry
 
Back
Top