Results 1 to 5 of 5

[SOLVED] Function tagging values with if statements

Threaded View

  1. #1
    Registered User
    Join Date
    02-25-2010
    Location
    Boston, MA
    MS-Off Ver
    Excel 2003
    Posts
    3

    Angry [SOLVED] Function tagging values with if statements

    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.
    Last edited by NBVC; 02-25-2010 at 12:18 PM.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1