+ Reply to Thread
Results 1 to 5 of 5

Nested IF formula

  1. #1
    Registered User
    Join Date
    02-08-2009
    Location
    Groton, CT
    MS-Off Ver
    Excel 2003
    Posts
    5

    Nested IF formula

    Help -

    In column 'H' I have calculated percentages. I need to be able to divide the rows based on the percentage derived in column H.
    The five categories I need to divide the data into are: 0% to <25%, 25% to <50%, 50% to <75%, 75% to < 90%, and 90% to 100%.
    Each of these categories will be given a numerical value of 1 through 5 so that 0-<25% = 1, 25-<50% = 2, 50-<75% = 3, 75-<90% = 4, and 90-100% = 5.

    I have tried this formula several different ways and none of them work. Here's a few of the ways that I tried and thought
    might work but didn't:



    =IF(($H2>=0.9), 5, IF(AND($H2>=0.75,$H2<=0.89)), 4, IF(AND($H2>=0.5,$H2<=0.74)), 3, IF(AND($H2>=0.25,$H2<=0.49)), 2, IF(AND($H2>=0.0,$H2<=0.24)), 1)
    =IF($H2>=0.9, 5, IF(AND($H2>=0.75,$H2<0.9)), 4, IF(AND($H2>=0.5,$H2<0.75)), 3, IF(AND($H2>=0.25,$H2<0.5)), 2, IF(AND($H2>=0.0,$H2<0.25)), 1)

    I even put the percentage values in seperate cells to reference but that didn't work either:
    =IF($H2>=$J$2,5,IF(AND($H2>=$J$3,$H2<$J$2)),4,IF(AND($H2>=$J$4,$H2<$J$3)),3,IF(AND($H2>=$J$5,$H2<$J$4)),2,IF(AND($H2>=$J$6,$H2<$J$5)),1)

    What am I doing wrong and what do I need to do to fix it?

    Mike
    Last edited by VBA Noob; 02-08-2009 at 03:19 PM.

  2. #2
    Forum Expert Ron Coderre's Avatar
    Join Date
    03-22-2005
    Location
    Boston, Massachusetts
    MS-Off Ver
    2013, 2016, O365
    Posts
    6,996

    Re: HELP - Complex nested IF formula

    For a single cell solution...
    Try this:

    Please Login or Register  to view this content.
    or...for more flexibility...

    Put this table in A1:B5

    Please Login or Register  to view this content.
    Then use this formula:
    Please Login or Register  to view this content.
    Does that help?
    Ron
    Former Microsoft MVP - Excel (2006 - 2015)
    Click here to see the Forum Rules

  3. #3
    Registered User
    Join Date
    02-08-2009
    Location
    Groton, CT
    MS-Off Ver
    Excel 2003
    Posts
    5

    Re: HELP - Complex nested IF formula

    I don't think that LOOKUP or the VLOOKUP function will work with what I have. It's looking for an exact number and I need to look at a range.
    Here's what I have (columns F, G, H, and I are the only columns containing working data so these are what I have copied here.

    Column H is the percentile of F/G. In column I, I need to place the numbers 1 through 5 based on the percentile in column H and the criteria previously posted ( 0% - <25% = 1, 25% - <50% = 2, 50% - <75% = 3, 75% - <90% = 4, 90% - 100% = 5 )

    row
    1 F G H I
    2 91 46 51%
    3 16 0 0%
    4 103 3 3%
    5 155 73 47%
    6 26 4 15%
    7 62 12 19%
    8 52 6 12%
    9 10 1 10%

  4. #4
    Forum Expert Ron Coderre's Avatar
    Join Date
    03-22-2005
    Location
    Boston, Massachusetts
    MS-Off Ver
    2013, 2016, O365
    Posts
    6,996

    Re: HELP - Complex nested IF formula

    Quote Originally Posted by MAPepin View Post
    I don't think that LOOKUP or the VLOOKUP function will work with what I have. It's looking for an exact number and I need to look at a range.
    Not true...See Excel Help for each of the functions:
    LOOKUP does not look for an exact match.
    VLOOKUP uses approximate matches when the 4th argument is 1 or omitted.
    MATCH uses approximate matches when the 3rd argument is 1 or omitted.

    Using the setup from my previous post and your percent samples in H1:H8
    AND...any of these formulas:

    Please Login or Register  to view this content.
    Copy the I1 formula down through I8.

    These are the returned values:
    Please Login or Register  to view this content.
    Are those value incorrect? Am I missing something?

  5. #5
    Valued Forum Contributor
    Join Date
    10-06-2008
    Location
    Norway
    MS-Off Ver
    2010
    Posts
    365

    Re: Nested IF formula

    Hi.
    Lookup will work just fine, but you could also use a nested IF formula as you first intended if you prefer that:

    Please Login or Register  to view this content.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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