I wrote a function to change a value in a cell to an ordinal number.
Function pvalueconversion(pval As Double)
If (pval < -0.05) Then pvalueconversion = "-1"
If (-0.05 < pval < -0.01) Then pvalueconversion = "-2"
If (-0.01 < pval < -0.003) Then pvalueconversion = "-3"
If (-0.003 < pval < -0.0003) Then pvalueconversion = "-4"
If (-0.0003 < pval < 0) Then pvalueconversion = "-5"
If (pval > 0.05) Then pvalueconversion = "1"
If (0.01 < pval < 0.05) Then pvalueconversion = "2"
If (0.003 < pval < 0.01) Then pvalueconversion = "3"
If (0.0003 < pval < 0.003) Then pvalueconversion = "4"
If (0 < pval < 0.0003) Then pvalueconversion = "5"
End Function
--- All postive values that get passed through the function return a value of "5." If I remove the postive value statements, I get the desired result for negative numbers. When I remove the last for lines, I get correct return of "1" for postiive values that satisfy the statement, however, if I remove the last three lines, I get a value of 2 for everything.
Is this function over defined? I don't understand why I can simply make nested if statements using If Else. I using Else and only got errors.
Bookmarks