+ Reply to Thread
Results 1 to 6 of 6

"Nested" If Statement trouble... example

  1. #1
    Registered User
    Join Date
    04-07-2010
    Location
    London
    MS-Off Ver
    Excel 2003
    Posts
    3

    "Nested" If Statement trouble... example

    Hopefully someone is much better at this than I am! I'll summarize my goal first, then display the formula I've tried below which doesn't work. Basically I have two cells. Cell D9 can be filled with either "Loan" or "Bond". Cell I9 can be filled with either "GBP","EUR", or "USD". So I have six possible combinations. My goal is that for whichever combination exists, to lookup a value (cell AA9) in one of 6 different corresponding tables on another tab called 'Base Rates', and show the answer to that VLOOKUP. Currently the formula returns FALSE. So it' a functioning formula but it's not working the way I want/expect it to. I appreciate any help. Thanks!

    =IF(AND(D9="Loan",I9="GBP"),VLOOKUP(AA9,'Base Rates'!$B$3:$C$75,2),IF(AND(D9="Loan",I9="EUR"),VLOOKUP(AA9,'Base Rates'!$E$3:$F$75,2),IF(AND(D9="Loan",I9="USD"),VLOOKUP(AA9,'Base Rates'!$H$3:$I$75,2),IF(AND(D9="Bond",I9="GBP"),VLOOKUP(AA9,'Base Rates'!$M$3:$N$75,2),IF(AND(D9="Bond",I9="EUR"),VLOOKUP(AA9,'Base Rates'!$P$3:$Q$75,2),IF(AND(D9="Bond",I9="USD"),VLOOKUP(AA9,'Base Rates'!$S$3:$T$75,2)))))))

  2. #2
    Forum Expert NBVC's Avatar
    Join Date
    12-06-2006
    Location
    Mississauga, CANADA
    MS-Off Ver
    2003:2010
    Posts
    34,898

    Re: "Nested" If Statement trouble... example

    If you name each of the 2 column tables through Insert|Name|Define... something like:

    LoanGP or BondGP (combining the D9 and I9 choices)...

    Then you can use Indirect...

    e.g. =Vlookup(AA9,Indirect(D9&I9),2,0)
    Last edited by NBVC; 04-07-2010 at 04:12 PM.
    Where there is a will there are many ways.

    If you are happy with the results, please add to the contributor's reputation by clicking the reputation icon (star icon) below left corner

    Please also mark the thread as Solved once it is solved. Check the FAQ's to see how.

  3. #3
    Forum Expert Paul's Avatar
    Join Date
    02-05-2007
    Location
    Wisconsin
    MS-Off Ver
    2016/365
    Posts
    6,885

    Re: "Nested" If Statement trouble... example

    Hi Mav88, welcome to the forum.

    Would you be able to upload a sample workbook that has your layout and some sample data and expected results? To hide the FALSE result (either D9 or I9 or both are blank) you just need to change the last bit like so:

    ... IF(AND(D9="Bond",I9="USD"),VLOOKUP(AA9,'Base Rates'!$S$3:$T$75,2),""))))))

    I think the formula itself could be shortened though, but would rather try on a real layout.

  4. #4
    Valued Forum Contributor tony h's Avatar
    Join Date
    03-14-2005
    Location
    England: London and Lincolnshire
    Posts
    1,187

    Re: "Nested" If Statement trouble... example

    Interested to see what Paul comes up with I am sure he will do a better job than I.

    I tend to dislike those If statements too prone to typing errors and hardwork to check.

    If you only have a couple to do something like:
    =CHOOSE(INT(FIND(D2&E2,"LoanUSD¦LoanGBP¦LoanEUR¦BondUSD¦BondGBP¦BondEUR¦",1)/8)+1,"vl"&1,"vl" & 2,vl3,vl4,vl5,vl5,vl6) BUT replace the vl1, vl2 etc with your vlookups.


    click on the * Add Reputation if this was useful or entertaining.

  5. #5
    Registered User
    Join Date
    04-07-2010
    Location
    London
    MS-Off Ver
    Excel 2003
    Posts
    3

    Re: "Nested" If Statement trouble... example

    Thanks for the suggestions, will try them out tomorrow and upload a sample workbook if I'm still having trouble.

  6. #6
    Registered User
    Join Date
    04-07-2010
    Location
    London
    MS-Off Ver
    Excel 2003
    Posts
    3

    Re: "Nested" If Statement trouble... example

    Follow up: I actually got the formula to work after realizing there were some extra spaces in the text cells, which were throwing it off. However, I still have 2 questions perhaps someone can help me with. I've uploaded a sample spreadsheet to make it easier.

    1) Regarding the VLOOKUPs, I'm trying to get the CLOSEST match in the table for the value I'm looking up. By default it seems to round down whereas I would like it to round to the NEAREST, up or down. Is there an easy fix here?

    2) If anyone feels up to the challenge, realizing writing so many IF statements is less than ideal for several reasons, I'm open to suggestions to make the formula simpler and still accomplish the same goal.

    Thanks very much.

    (note ignore the original formula i first posted since the cells have changed).
    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)

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