+ Reply to Thread
Results 1 to 7 of 7

How Do I Program Multiple Conditions within a Cell in Excel?

  1. #1
    Forum Contributor
    Join Date
    05-29-2009
    Location
    Chattanooga, TN
    MS-Off Ver
    2021
    Posts
    205

    How Do I Program Multiple Conditions within a Cell in Excel?

    Trying to program cell C1:

    If A1 is between .81 and 3, AND if B1 is Adult, then C1 is Priority Mail
    If A1 is greater than 3, AND if B1 is Adult, then C1 is FedEx Ground
    If A1 is Less than .81, AND if B1 is Adult, then C1 is First Class Mail
    If A1 is Less than .81, AND if B1 is Child, then C1 is Hold for Inspection

    etc.

    There will be a list of ~45 conditions that will populate a specific value in C1. Can this be done? If so, how?

    Thanks
    Ocean
    Last edited by Ocean Zhang; 06-11-2009 at 04:17 PM.

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

    Re: How Do I Program Multiple Conditions within a Cell in Excel?

    Create separate lists for Adult, Child, etc...

    show the bottom ranges in ascending order starting from 0 in one column and next to it the text string you would like returned... then use Lookup() function with IF() to get data..

    e.g. =IF(B1="ADULT",Lookup(A1,Adult_Range),if(B1="CHILD",Lookup(A1,Child_Range), etc..)

    or shorter

    =Lookup(A1,IF(B1="ADULT",Adult_Range,if(B1="CHILD",Child_Range),etc...)

    or if you further name each range like ADULT, CHILD...

    Then simply: =LOOKUP(A1,INDIRECT(B1))
    Last edited by NBVC; 06-03-2009 at 03:42 PM. Reason: Included INDIRECT in last formula to be able to use Named Ranges
    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 Contributor
    Join Date
    05-29-2009
    Location
    Chattanooga, TN
    MS-Off Ver
    2021
    Posts
    205

    Re: How Do I Program Multiple Conditions within a Cell in Excel?

    Thanks for your help, but I'm having a hard time understanding. I must have read over your post over a hundred times and I still can't get it

    Can you perhaps attach a short example?

    Thanks
    Ocean

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

    Re: How Do I Program Multiple Conditions within a Cell in Excel?

    Ok, see attached....

    I showed 2 options...

    First Option is in the case that you have different ranges for the different categories (i.e. Adult, Child, etc.)

    So I listed the Adult specs in I1:J4 and the Child specs in K1:L4

    I named each of those 2 tables through Insert|Name|Define as "Adult" and "Child" respectively...

    Then formula in C1 is:
    Please Login or Register  to view this content.
    This looks at value in A1 in one of those 2 tables based on what is in B1.

    Option 2 is for if the ranges are always the same but you have different text returned based on the category..

    So now I named range I8:J11 as "AdultRange" and then I8:K11 as "ChildRange".. Note: Lookup() looks up in the first column of the range and returns from the last column in the specified range...

    Formula in C9:
    Please Login or Register  to view this content.
    Test out which ever you prefer and apply...
    Attached Files Attached Files
    Last edited by NBVC; 06-08-2009 at 12:45 PM.

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

    Re: How Do I Program Multiple Conditions within a Cell in Excel?

    Here is a sample using the shorter: =Lookup(A1,Indirect(B1)) if you name the ranges as per what you write in B1...

    See formula in D1
    Attached Files Attached Files

  6. #6
    Forum Contributor
    Join Date
    05-29-2009
    Location
    Chattanooga, TN
    MS-Off Ver
    2021
    Posts
    205

    Re: How Do I Program Multiple Conditions within a Cell in Excel?

    Thank you SOOOOOOOO much for your help. This will be extremely helpful. I couldn't get your second example to work though. I don't think I'm naming the ranges or tables correctly.

    I have another related question. Should I start a new thread or post the question within this one?

    Thanks!
    Ocean

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

    Re: How Do I Program Multiple Conditions within a Cell in Excel?

    Probably should be a new thread.. unless it is directly related to the same initial question here.

+ 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