ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Worksheet Functions (https://www.excelbanter.com/excel-worksheet-functions/)
-   -   Basic Probabilities UDF Function Help (https://www.excelbanter.com/excel-worksheet-functions/270261-basic-probabilities-udf-function-help.html)

Joe Smith03

Basic Probabilities UDF Function Help
 
Ive written a very basic UDF function to calculate 2 probabilities given several potential variables, but I keep receiving this error message and I am entirely stumped as to what to do. This is my first time using UDF, if someone could give me some pointers, I would greatly appreciate it. I have posted what I have written below.

Function PD(a As Variant, x As Variant, z As Variant)
PD = [a(1.00-x)] + [z(1.00-a)]
End Function
Function PS(a As Variant, x As Variant, z As Variant)
PS = (a * x) + [(1.00-a)*(1.00-z)]
End Function

But when I move to an excel sheet, and insert the respective equation, including telling the function which cells it should extract the variables from for the specific problem...I receive the error messagešValue!š

Help?

Joe Smith03

Quote:

Originally Posted by Joe Smith03 (Post 964625)
Ive written a very basic UDF function to calculate 2 probabilities given several potential variables, but I keep receiving this error message and I am entirely stumped as to what to do. This is my first time using UDF, if someone could give me some pointers, I would greatly appreciate it. I have posted what I have written below.

Function PD(a As Variant, x As Variant, z As Variant)
PD = [a(1.00-x)] + [z(1.00-a)]
End Function
Function PS(a As Variant, x As Variant, z As Variant)
PS = (a * x) + [(1.00-a)*(1.00-z)]
End Function

But when I move to an excel sheet, and insert the respective equation, including telling the function which cells it should extract the variables from for the specific problem...I receive the error messagešValue!š

Help?



No? No one has any idea what I might be doing wrong? How disappointing. Ok.

tarquinious

Sorry your query has gone so long without a response.

I believe your issue is because of the square brackets you're using in the calculation. I don't think Excel likes these.

The way to tell is to copy and paste your calculation straight into a cell in the workbook and see what the error message is - errors are suppressed when using a Function and all you get is "#NAME?" as a result if there is an error in the function.

Try using round brackets (e.g.):
PS = (a * x) + ((1 - a) * (1 - z))

Further to this, you also need to put in your multiplication signs in the PD function as Excel does not use the notation xy meaning x * y.
PD = (a * (1 - x)) + (z * (1 - a))

I hope this helps.

Joe Smith03

Quote:

Originally Posted by tarquinious (Post 964711)
Sorry your query has gone so long without a response.

I believe your issue is because of the square brackets you're using in the calculation. I don't think Excel likes these.

The way to tell is to copy and paste your calculation straight into a cell in the workbook and see what the error message is - errors are suppressed when using a Function and all you get is "#NAME?" as a result if there is an error in the function.

Try using round brackets (e.g.):
PS = (a * x) + ((1 - a) * (1 - z))

Further to this, you also need to put in your multiplication signs in the PD function as Excel does not use the notation xy meaning x * y.
PD = (a * (1 - x)) + (z * (1 - a))

I hope this helps.



THANKS FOR THE HELP, I APPRECIATE IT. UNFORTUNATELY IM GOING TO HAVE TO CONTINUE SEARCHING FOR MY ANSWER.


All times are GMT +1. The time now is 10:45 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com