+ Reply to Thread
Results 1 to 22 of 22

Multiple Ifs Problem

  1. #1
    Registered User
    Join Date
    07-24-2012
    Location
    Ireland
    MS-Off Ver
    Excel 2010
    Posts
    10

    Multiple Ifs Problem

    Hi,

    I'm hoping somebody can help me with the attached; I've been trying all day without success!!

    I have a figure in Cell A3.
    It is compared against 5 different figures.
    Depending on the criteria it matches, it will result in 5 possible figures.

    The attached should explain it better.

    Thanks in advance for any help.
    Attached Files Attached Files

  2. #2
    Forum Expert Tony Valko's Avatar
    Join Date
    12-31-2011
    Location
    Pittsburgh
    MS-Off Ver
    2002, 2007:2013
    Posts
    18,890

    Re: Multiple Ifs Problem

    See if this helps:

    http://contextures.com/xlFunctions02.html
    Biff
    Microsoft MVP Excel
    Keep It Simple Stupid

    Let's Go Pens. We Want The Cup.

  3. #3
    Forum Expert etaf's Avatar
    Join Date
    10-22-2004
    Location
    Wittering, West Sussex, UK
    MS-Off Ver
    365 (Mac OSX) (16.83 (24031120))
    Posts
    8,745

    Re: Multiple Ifs Problem

    to lookup the nearest highest value with vlookup (the usual is the lowest or the exact)
    you can use this
    =VLOOKUP(SMALL(D3:D7,COUNTIF(D3:D7,"<"&A3)+1),D3:G7,4)

    which will return the result you need

    the 2nd IF
    =IF(A3<D3,G3*-1,"")

    see attached
    Attached Files Attached Files

  4. #4
    Registered User
    Join Date
    07-24-2012
    Location
    Ireland
    MS-Off Ver
    Excel 2010
    Posts
    10

    Re: Multiple Ifs Problem

    Hi,

    Thanks for your replies so far - i've tried implementing the suggestions but i'm still struggling (sorry).

    I've attached the file again with some minor modifications and hopefully it will make things easier to solve.

    Thanks again, i really appreciate the help.

    Attachment:
    ifs.xls

  5. #5
    Forum Expert etaf's Avatar
    Join Date
    10-22-2004
    Location
    Wittering, West Sussex, UK
    MS-Off Ver
    365 (Mac OSX) (16.83 (24031120))
    Posts
    8,745

    Re: Multiple Ifs Problem

    do you need the layout as described as that is a lot different and will not work with the vlookup i posted

  6. #6
    Registered User
    Join Date
    07-24-2012
    Location
    Ireland
    MS-Off Ver
    Excel 2010
    Posts
    10

    Re: Multiple Ifs Problem

    yes the new layout is the one i want. i was hoping to adapt your formula but was unsuccessful.

    thanks again for your help.

  7. #7
    Forum Expert etaf's Avatar
    Join Date
    10-22-2004
    Location
    Wittering, West Sussex, UK
    MS-Off Ver
    365 (Mac OSX) (16.83 (24031120))
    Posts
    8,745

    Re: Multiple Ifs Problem

    no you cant adapt Vlookup very easily

    you will need to use an index match with a -1 option, but that needs the data sorted descending to work
    then you have target in one table and then band in the 2nd - so it would then have to extract just the letter to be able lookup on the 2nd table
    and if its just an example any slight changes are going to cause an issue

    I think to do this will probably need a macro - not my area

    is the layout and terms exactly as you would be using them in the production version of excel

  8. #8
    Forum Expert martindwilson's Avatar
    Join Date
    06-23-2007
    Location
    London,England
    MS-Off Ver
    office 97 ,2007
    Posts
    19,320

    Re: Multiple Ifs Problem

    these are the actual values in col c is that correct?
    275.352913
    344.191141
    430.238927
    537.798658
    672.248323
    "Unless otherwise stated all my comments are directed at OP"

    Mojito connoisseur and now happily retired
    where does code go ?
    look here
    how to insert code

    how to enter array formula

    why use -- in sumproduct
    recommended reading
    wiki Mojito

    how to say no convincingly

    most important thing you need
    Martin Wilson: SPV
    and RSMBC

  9. #9
    Registered User
    Join Date
    07-24-2012
    Location
    Ireland
    MS-Off Ver
    Excel 2010
    Posts
    10

    Re: Multiple Ifs Problem

    Quote Originally Posted by etaf View Post
    no you cant adapt Vlookup very easily

    you will need to use an index match with a -1 option, but that needs the data sorted descending to work
    then you have target in one table and then band in the 2nd - so it would then have to extract just the letter to be able lookup on the 2nd table
    and if its just an example any slight changes are going to cause an issue

    I think to do this will probably need a macro - not my area

    is the layout and terms exactly as you would be using them in the production version of excel
    yes the layout is the final production version. i appreciate taking the time to look into this; I'll keep trying.

  10. #10
    Registered User
    Join Date
    07-24-2012
    Location
    Ireland
    MS-Off Ver
    Excel 2010
    Posts
    10

    Re: Multiple Ifs Problem

    Quote Originally Posted by martindwilson View Post
    these are the actual values in col c is that correct?
    275.352913
    344.191141
    430.238927
    537.798658
    672.248323
    Yes those are correct. they are copied from a different source so i have them rounded to the nearest whole number

  11. #11
    Forum Expert martindwilson's Avatar
    Join Date
    06-23-2007
    Location
    London,England
    MS-Off Ver
    office 97 ,2007
    Posts
    19,320

    Re: Multiple Ifs Problem

    they may affect any lookup if you need to round them use a formula formatting wont work
    for example 537.798658 rounds to 538 if you tried to match 538 with that it wouldnt

  12. #12
    Forum Guru (RIP) Marcol's Avatar
    Join Date
    12-23-2009
    Location
    Fife, Scotland
    MS-Off Ver
    Excel '97 & 2003/7
    Posts
    7,216

    Re: Multiple Ifs Problem

    Maybe this?
    Formula: copy to clipboard
    Please Login or Register  to view this content.
    Attached Files Attached Files
    Last edited by Marcol; 06-12-2013 at 07:21 AM.
    If you need any more information, please feel free to ask.

    However,If this takes care of your needs, please select Thread Tools from menu above and set this topic to SOLVED. It helps everybody! ....

    Also
    اس کی مدد کرتا ہے اگر
    شکریہ کہنے کے لئے سٹار کلک کریں
    If you are satisfied by any members response to your problem please consider using the small Star icon bottom left of their post to show your appreciation.

  13. #13
    Forum Expert etaf's Avatar
    Join Date
    10-22-2004
    Location
    Wittering, West Sussex, UK
    MS-Off Ver
    365 (Mac OSX) (16.83 (24031120))
    Posts
    8,745

    Re: Multiple Ifs Problem

    as you are looking for the highest , nearest value

    this as an array formula will pull the first bit of info from table 1
    =INDEX(B5:B9,MATCH(MIN(IF(C5:C9-C2>=0,C5:C9,FALSE)),IF(C5:C9-C2>=0,C5:C9,FALSE),0))
    and enter as an array formula

    returns target D for your example

    now you need to look up band D to find the value

    to do that , we need to strip the last character from target D to get D
    and then lookup the BAND ? , so we also need to strip off Band to get the last character to search for D in that table

    So we return the highest nearest value using the above array - and then we get the last character , as that is the only bit common on both tables , using Right()

    then we use index match again , but have to look at just the last character in the band column using right() again to lookup the adjacent column to get a value

    so we get target D in your example and then right() to get the D
    then we lookup for the last character being D in the 2nd table

    but any changes in the tables or the names used , will, stop the formula from working at all

    so put this into C17

    =INDEX(C11:C15,MATCH(RIGHT(INDEX(B5:B9,MATCH(MIN(IF(C5:C9-C2>=0,C5:C9,FALSE)),IF(C5:C9-C2>=0,C5:C9,FALSE),0)),1),RIGHT(B11:B15,1),0))
    and then use an array
    todo that- you use the control + shift + enter keys - so you get {} around the formula

    see attached spreadsheet with the result using the above formula

    for the -ve value

    =IF(C2<C5,C11*-1,"")
    Last edited by etaf; 06-12-2013 at 07:39 AM.

  14. #14
    Forum Expert
    Join Date
    07-20-2011
    Location
    Mysore, India.
    MS-Off Ver
    Excel 2019
    Posts
    8,587

    Re: Multiple Ifs Problem

    in B11 use

    Please Login or Register  to view this content.
    In B17 Use

    Please Login or Register  to view this content.

  15. #15
    Forum Expert etaf's Avatar
    Join Date
    10-22-2004
    Location
    Wittering, West Sussex, UK
    MS-Off Ver
    365 (Mac OSX) (16.83 (24031120))
    Posts
    8,745

    Re: Multiple Ifs Problem

    @kvsrinivasamurthy the OP has changed the layout of the table in post #4
    so they are now two separate tables without a common link apart from part of the text

  16. #16
    Registered User
    Join Date
    07-24-2012
    Location
    Ireland
    MS-Off Ver
    Excel 2010
    Posts
    10

    Re: Multiple Ifs Problem

    Quote Originally Posted by etaf View Post
    as you are looking for the highest , nearest value

    this as an array formula will pull the first bit of info from table 1
    =INDEX(B5:B9,MATCH(MIN(IF(C5:C9-C2>=0,C5:C9,FALSE)),IF(C5:C9-C2>=0,C5:C9,FALSE),0))
    and enter as an array formula

    returns target D for your example

    now you need to look up band D to find the value

    to do that , we need to strip the last character from target D to get D
    and then lookup the BAND ? , so we also need to strip off Band to get the last character to search for D in that table

    So we return the highest nearest value using the above array - and then we get the last character , as that is the only bit common on both tables , using Right()

    then we use index match again , but have to look at just the last character in the band column using right() again to lookup the adjacent column to get a value

    so we get target D in your example and then right() to get the D
    then we lookup for the last character being D in the 2nd table

    but any changes in the tables or the names used , will, stop the formula from working at all

    so put this into C17

    =INDEX(C11:C15,MATCH(RIGHT(INDEX(B5:B9,MATCH(MIN(IF(C5:C9-C2>=0,C5:C9,FALSE)),IF(C5:C9-C2>=0,C5:C9,FALSE),0)),1),RIGHT(B11:B15,1),0))
    and then use an array
    todo that- you use the control + shift + enter keys - so you get {} around the formula

    see attached spreadsheet with the result using the above formula

    for the -ve value

    =IF(C2<C5,C11*-1,"")

    Many thanks @etaf, this is exactly what i want. except i did forget to say if the Total figure exceeds the Band E target, then the desired result is also Band E. At the moment it displays #N/A but that's my fault for not explaining it fully.

    For example, if C2 equals 700, then C17 should show the Band E price.

    Sorry for omitting this detail; i hope you can update the formula without too much trouble.

    Thanks again.

  17. #17
    Forum Expert etaf's Avatar
    Join Date
    10-22-2004
    Location
    Wittering, West Sussex, UK
    MS-Off Ver
    365 (Mac OSX) (16.83 (24031120))
    Posts
    8,745

    Re: Multiple Ifs Problem

    simple enough , just add an if at the front

    =IF(C2>C9,C15,INDEX(C11:C15,MATCH(RIGHT(INDEX(B5:B9,MATCH(MIN(IF(C5:C9-C2>=0,C5:C9,FALSE)),IF(C5:C9-C2>=0,C5:C9,FALSE),0)),1),RIGHT(B11:B15,1),0)))
    and still use
    control+shift+enter

  18. #18
    Registered User
    Join Date
    07-24-2012
    Location
    Ireland
    MS-Off Ver
    Excel 2010
    Posts
    10

    Re: Multiple Ifs Problem

    Quote Originally Posted by etaf View Post
    simple enough , just add an if at the front

    =IF(C2>C9,C15,INDEX(C11:C15,MATCH(RIGHT(INDEX(B5:B9,MATCH(MIN(IF(C5:C9-C2>=0,C5:C9,FALSE)),IF(C5:C9-C2>=0,C5:C9,FALSE),0)),1),RIGHT(B11:B15,1),0)))
    and still use
    control+shift+enter
    that's perfect; thanks a million.

    one last thing, the Code in D22 below should change from:
    Please Login or Register  to view this content.

  19. #19
    Forum Expert etaf's Avatar
    Join Date
    10-22-2004
    Location
    Wittering, West Sussex, UK
    MS-Off Ver
    365 (Mac OSX) (16.83 (24031120))
    Posts
    8,745

    Re: Multiple Ifs Problem

    d22 and d23 , was me playing and testing - you can ignore those

  20. #20
    Registered User
    Join Date
    07-24-2012
    Location
    Ireland
    MS-Off Ver
    Excel 2010
    Posts
    10

    Re: Multiple Ifs Problem

    fair enough @etaf, thanks a million for your help - i really appreciate it.

  21. #21
    Forum Expert etaf's Avatar
    Join Date
    10-22-2004
    Location
    Wittering, West Sussex, UK
    MS-Off Ver
    365 (Mac OSX) (16.83 (24031120))
    Posts
    8,745

    Re: Multiple Ifs Problem

    your welcome
    new to the forum, but if you click on the * that adds to my reputation

  22. #22
    Forum Expert
    Join Date
    07-20-2011
    Location
    Mysore, India.
    MS-Off Ver
    Excel 2019
    Posts
    8,587

    Re: Multiple Ifs Problem

    Pl see the attached file.

    Please Login or Register  to view this content.
    Attached Files Attached Files

+ 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