+ Reply to Thread
Results 1 to 2 of 2

If formula used for multiple outcomes

  1. #1
    Registered User
    Join Date
    07-14-2009
    Location
    Brisbane,Australia
    MS-Off Ver
    Excel 2004
    Posts
    4

    If formula used for multiple outcomes

    Hello, i have a 2 columns 1 which brings back values between 1 and 7 and the other 1-2.

    =if(A1=2,B1=1),"div 5","") quite simple i know...

    However i want to put multiple outcomes in the 1 cell depending on the numbers which fall in the A and B cells

    so in addition to the formula above i also want to say

    =if(A1=3,B1=1),"div4","") and =if(A1=4,B1=1),"div 3","") and so on

    Basically when the A1 cell number goes up the "true value" changes...

    can this be done with an 'if', 'and' or 'or' formula?

    Kind regards,
    Last edited by Scottiexcel; 07-14-2009 at 11:31 PM.

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

    Re: If formula used for multiple outcomes

    Hi Scottie, welcome to the forum.

    Based on your information, I would assume there are 14 different combinations of A1 and B1:
    1 and 1 ... 2 and 1 ... 3 and 1 ... 4 and 1 ... 5 and 1 ... 6 and 1 ... 7 and 1
    1 and 2 ... 2 and 2 ... 3 and 2 ... 4 and 2 ... 5 and 2 ... 6 and 2 ... 7 and 2

    You can only have up to 7 nested IF functions in older versions of Excel, so instead a LOOKUP may work for you. Try:

    =LOOKUP(A1&B1,{"11","12","21","22","31","32","41","42","51","52","61","62","71","72"},{"div6","div13","div5","div12","div4","div11","div3","div10","div2","div9","div1","div8","div0","div7"})

    This formula concatenates the values in A1 and B1 (e.g. A1=1, B1=1 then result is "11"). It then compares that concatenation to the first array of values {"11","12","21"..}. Notice that the first array is in ASCENDING order, it's not just {"11","21","31","41",...,"12","22","32"..} because for LOOKUP to work it must be that way.

    When it finds a match in the first array, it then retrieves the value in the same position of the second array, {"div6", "div13", "div5", ...}. For each item in the first array, there is a corresponding second array. So because your items in the first array are in ascending order, you must arrange your second array so that the results correspond. Hopefully that makes sense?

+ 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