+ Reply to Thread
Results 1 to 23 of 23

more than 8 if's are not working in a cell

  1. #1
    Registered User
    Join Date
    05-31-2010
    Location
    cbe, india
    MS-Off Ver
    Excel 2021
    Posts
    16

    Thumbs up more than 8 if's are not working in a cell

    Friends,

    I am new to this forum....nice to meet you all...
    Below is working fine....

    =IF(D4=5,31,IF(D4=10,56,IF(D4=15,83,IF(D4=20,110,IF(D4=25,135,IF(D4=50,268,IF(D4=100,530,IF(D4=200,1050))))))))
    but if i add another if like below

    then i am getting an error as "the formula containing an error

    =IF(D4=5,31,IF(D4=10,56,IF(D4=15,83,IF(D4=20,110,IF(D4=25,135,IF(D4=50,268,IF(D4=100,530,IF(D4=200,1050,IF(D4=200,1560)))))))))
    where i am making mistake?

    thanks
    Last edited by sathyguy; 05-31-2010 at 09:22 AM.

  2. #2
    Forum Contributor
    Join Date
    03-11-2010
    Location
    India
    MS-Off Ver
    2010
    Posts
    268

    Re: more than 8 if's are not working in a cell

    You are not making any mistake. The IF function is limited to 8 nestings by Excel.

    hth
    Ajay

  3. #3
    Registered User
    Join Date
    05-31-2010
    Location
    cbe, india
    MS-Off Ver
    Excel 2021
    Posts
    16

    Re: more than 8 if's are not working in a cell

    oh.thanks.....so what is the solution for another 3 if's...?

  4. #4
    Forum Contributor
    Join Date
    03-11-2010
    Location
    India
    MS-Off Ver
    2010
    Posts
    268

    Re: more than 8 if's are not working in a cell

    I think a lookup should work for you.

    hth
    Ajay

  5. #5
    Valued Forum Contributor squiggler47's Avatar
    Join Date
    02-17-2009
    Location
    Littleborough, UK
    MS-Off Ver
    Excel 3.0 to 2007+2010! (couldnt get 2.1 working)
    Posts
    1,013

    Re: more than 8 if's are not working in a cell

    you could do this :-

    =IF(D4>200,1560,IF(ISERROR(INDEX({31,56,83,110,135,268,530,1050},1,MATCH(D4,{5,10,15,20,25,50,100,200},0))),-1,INDEX({31,56,83,110,135,268,530,1050},1,MATCH(D4,{5,10,15,20,25,50,100,200},0))))

    I assumed that your formula would return 1560 if the value is above 200

    The red is the values you want in the cell, and the blue is the value that is in cell d4, you can add as many terms as you want!

    it would be better to put the values in a cell and refer to it than hard coding in the formula!

    it returns -1 if the value is not found
    Regards
    Darren

    Update 12-Nov-2010 Still job hunting!

    If you are happy with the results, please add to our reputation by clicking the blue scales icon in the blue bar of the post.

    Learn something new each day, Embrace change do not fear it, evolve and do not become extinct!


  6. #6
    Registered User
    Join Date
    05-31-2010
    Location
    cbe, india
    MS-Off Ver
    Excel 2021
    Posts
    16

    Re: more than 8 if's are not working in a cell

    I am doing this in the column "P" ... can you help me how to achieve this?
    actually, when i type value in column "D", then the value equal to the column "D" should be displayed in column "P"...
    example.
    if i type 5 in D4 then in P4 the value should be 31

  7. #7
    Forum Expert
    Join Date
    12-03-2009
    Location
    Florence, Italy
    MS-Off Ver
    Excel 2019
    Posts
    1,796

    Re: more than 8 if's are not working in a cell

    Hi, a vlookup like the following could give you more room to move.

    Sorry if I did not put the right correspondences (in the example 5 becomes 31 20 becomes 110 ...)

    =VLOOKUP(D4,{5,31\20,110\25,135\50,268\100,530\200,1050},2,false)

    You can adjust the false/true option or you can nest the formula into a shorter IF .

    =IF(D4<5;....;FORMULA)

    Hope it helps
    Last edited by canapone; 05-31-2010 at 08:19 AM.

  8. #8
    Valued Forum Contributor squiggler47's Avatar
    Join Date
    02-17-2009
    Location
    Littleborough, UK
    MS-Off Ver
    Excel 3.0 to 2007+2010! (couldnt get 2.1 working)
    Posts
    1,013

    Re: more than 8 if's are not working in a cell

    Quote Originally Posted by sathyguy View Post
    I am doing this in the column "P" ... can you help me how to achieve this?
    actually, when i type value in column "D", then the value equal to the column "D" should be displayed in column "P"...
    example.
    if i type 5 in D4 then in P4 the value should be 31
    just put my formula in P4 then copy down!

  9. #9
    Forum Moderator zbor's Avatar
    Join Date
    02-10-2009
    Location
    Croatia
    MS-Off Ver
    365 ProPlus
    Posts
    15,602

    Re: more than 8 if's are not working in a cell

    You didn't write what if D4 is 200?
    You have two same answers.....
    This one maybe?

    =LOOKUP(D4,{0,5,10,15,20,25,50,100,200},{0,31,56,83,110,135,268,530,1050})

  10. #10
    Registered User
    Join Date
    05-31-2010
    Location
    cbe, india
    MS-Off Ver
    Excel 2021
    Posts
    16

    Re: more than 8 if's are not working in a cell

    @canapone....
    its giving error...

  11. #11
    Registered User
    Join Date
    05-31-2010
    Location
    cbe, india
    MS-Off Ver
    Excel 2021
    Posts
    16

    Re: more than 8 if's are not working in a cell

    @squiggler47
    this is what....i want...

    =IF(D4=5,31,IF(D4=10,56,IF(D4=15,83,IF(D4=20,110,IF(D4=25,135,IF(D4=50,268,IF(D4=100,530,IF(D4=200,1050,IF(D4=300,1560,IF(D4=400,2050,IF(D4=500,2550)))))))))))

  12. #12
    Registered User
    Join Date
    05-31-2010
    Location
    India
    MS-Off Ver
    Excel 2007
    Posts
    3

    Re: more than 8 if's are not working in a cell

    sathyguy,

    you should use Choose() function to achieve what you wanted to achieve with nested IF

    Excel Matic

  13. #13
    Valued Forum Contributor squiggler47's Avatar
    Join Date
    02-17-2009
    Location
    Littleborough, UK
    MS-Off Ver
    Excel 3.0 to 2007+2010! (couldnt get 2.1 working)
    Posts
    1,013

    Re: more than 8 if's are not working in a cell

    =IF(D4>200,1560,IF(ISERROR(INDEX({31,56,83,110,135,268,530,1050},1,MATCH(D4,{5,10,15,20,25,50,100,200},0))),FALSE,INDEX({31,56,83,110,135,268,530,1050},1,MATCH(D4,{5,10,15,20,25,50,100,200},0))))

    again Lookup is providing different results to the OP!

    I changed the -1 to FALSE, so any value not in the list will produce FALSE

  14. #14
    Registered User
    Join Date
    05-31-2010
    Location
    cbe, india
    MS-Off Ver
    Excel 2021
    Posts
    16

    Re: more than 8 if's are not working in a cell

    @squiggler47
    Still if i enter any not listed numbers its not showing as false.
    its showing the previous value.

  15. #15
    Valued Forum Contributor squiggler47's Avatar
    Join Date
    02-17-2009
    Location
    Littleborough, UK
    MS-Off Ver
    Excel 3.0 to 2007+2010! (couldnt get 2.1 working)
    Posts
    1,013

    Re: more than 8 if's are not working in a cell

    Quote Originally Posted by sathyguy View Post
    @squiggler47
    Still if i enter any not listed numbers its not showing as false.
    its showing the previous value.
    the last formula sent by me, behaves exactly like yours!

    make sure you add the numbers to both sets!

  16. #16
    Registered User
    Join Date
    05-31-2010
    Location
    cbe, india
    MS-Off Ver
    Excel 2021
    Posts
    16

    Re: more than 8 if's are not working in a cell

    thanks...below one is working fine...
    =IF(D4>500,2550,IF(ISERROR(INDEX({31,56,83,110,135,268,530,1050,1560,2060,2550},1,MATCH(D4,{5,10,15,20,25,50,100,200,300,400,500},0))),FALSE,INDEX({31,56,83,110,135,268,530,1050,1560,2060,2550},1,MATCH(D4,{5,10,15,20,25,50,100,200,300,400,500},0))))

    but the problem is ....
    if i enter 501 or above then its not showing false.

  17. #17
    Valued Forum Contributor squiggler47's Avatar
    Join Date
    02-17-2009
    Location
    Littleborough, UK
    MS-Off Ver
    Excel 3.0 to 2007+2010! (couldnt get 2.1 working)
    Posts
    1,013

    Re: more than 8 if's are not working in a cell

    =if(d4>500,false,if(iserror(index({31,56,83,110,135,268,530,1050,1560,2060,2550},1,match(d4,{5,10,15, 20,25,50,100,200,300,400,500},0))),false,index({31,56,83,110,135,268,530,1050,1560,2060,2550},1,matc h(d4,{5,10,15,20,25,50,100,200,300,400,500},0))))

  18. #18
    Forum Expert daddylonglegs's Avatar
    Join Date
    01-14-2006
    Location
    England
    MS-Off Ver
    2016
    Posts
    14,675

    Re: more than 8 if's are not working in a cell

    The simplest way, I think, is to create a lookup table,

    For example list the possible values for D4 in Y2:Y12 and the corresponding values you want to return in Z2:Z12, e.g. Y2 = 5, Z2 =31, Y3 = 10, Z3 = 56 etc. then you can use this formula

    =VLOOKUP(D4,$Y$2:$Z$12,2,0)

    or if you really don't want a lookup table then you can put those values in the formula, i.e.

    =VLOOKUP(D4,{5,31;10,56;15,83;20,110;25,135;50,268;100,530;200,1050;300,1560;400,2050;500,2550},2,0)

    If D4 isn't any of those values you'll get #N/A

  19. #19
    Valued Forum Contributor squiggler47's Avatar
    Join Date
    02-17-2009
    Location
    Littleborough, UK
    MS-Off Ver
    Excel 3.0 to 2007+2010! (couldnt get 2.1 working)
    Posts
    1,013

    Re: more than 8 if's are not working in a cell

    or even :-

    =if(iserror(index({31,56,83,110,135,268,530,1050,1560,2060,2550},1,match(d4,{5,10,15 , 20,25,50,100,200,300,400,500},0))),false,index({31,56,83,110,135,268,530,1050,1560,2060,2550},1,match(d4,{5,10,15,20,25,50,100,200,300,400,500},0)))

    I had made an assumption on your original formula, this will return false if it is not in the list!

  20. #20
    Registered User
    Join Date
    05-08-2010
    Location
    Qatar
    MS-Off Ver
    Excel 2003
    Posts
    24

    Re: more than 8 if's are not working in a cell

    Use COUNTIF formula, sure it will work

  21. #21
    Registered User
    Join Date
    05-31-2010
    Location
    cbe, india
    MS-Off Ver
    Excel 2021
    Posts
    16

    Re: more than 8 if's are not working in a cell

    @squiggler47 ------ you are great.....

    this is what i want.......thank you so much...

  22. #22
    Forum Expert daddylonglegs's Avatar
    Join Date
    01-14-2006
    Location
    England
    MS-Off Ver
    2016
    Posts
    14,675

    Re: more than 8 if's are not working in a cell

    If you use a table and really want FALSE as a result when D4 is none of those values you can amend the VLOOKUP as follows

    =IF(COUNTIF($Y$2:$Y$12,D4),VLOOKUP(D4,$Y$2:$Z$12,2,0))

  23. #23
    Valued Forum Contributor Miraun's Avatar
    Join Date
    04-03-2009
    Location
    New England
    MS-Off Ver
    2003, 2007, 2010, 2013
    Posts
    554

    Re: more than 8 if's are not working in a cell

    REALLY overcomplicated the answer...

    I've had many problems with imbedded if statement.

    Here's what you originally had:
    =IF(D4=5,31,IF(D4=10,56,IF(D4=15,83,IF(D4=20,110,IF(D4=25,135,IF(D4=50,268,IF(D4=100,530,IF(D4=200,1 050))))))))

    Here's the proposed change:
    =If(D4=5,31,0)+If(D4=10,56,0)+... etc...etc
    Then you're just adding up 0s unless it's the value you're looking for.

+ 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