+ Reply to Thread
Results 1 to 12 of 12

Nested IF conditional on many cells...

  1. #1
    Registered User
    Join Date
    09-27-2015
    Location
    London
    MS-Off Ver
    Office 13
    Posts
    20

    Nested IF conditional on many cells...

    Hi all, trying to get a formula that executes the following if a number of conditions are met, but struggling a bit.

    If cell range C21:28 all equal 'value x' then in cell C34 display 'Statement A'
    If cell range C21:28 all equal 'value x' and cell range C29:31 all equal 'value y' then in cell C34 display 'Statement B'
    If cell range C21:28 all equal 'value x' and cell range C29:31 all equal 'value y' and cell range C32:33 all equal 'value z' then in cell C34 display 'Statement C'
    If none of the above apply, then in cell C34 display 'Statement D'

    Thanks in advance.

  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: Nested IF conditional on many cells...

    Is/are 'value x, y and z' numbers or text strings or both?
    Biff
    Microsoft MVP Excel
    Keep It Simple Stupid

    Let's Go Pens. We Want The Cup.

  3. #3
    Registered User
    Join Date
    09-27-2015
    Location
    London
    MS-Off Ver
    Office 13
    Posts
    20

    Re: Nested IF conditional on many cells...

    Hi Tony and thanks for your reply.

    They are numbers, but I'd like it not to matter if they are text strings, as I'd like to adapt this worksheet in the future for other purposes.

    Regards

  4. #4
    Forum Guru Jonmo1's Avatar
    Join Date
    03-08-2013
    Location
    Bryan, TX
    MS-Off Ver
    Excel 2010
    Posts
    9,763

    Re: Nested IF conditional on many cells...

    Is it a situation where 'Value x' will be filled incrimentally from the top down?

    i.e., C25 will never equal 'value x' if C21:C24 do not already equal 'value x' ??

  5. #5
    Registered User
    Join Date
    09-27-2015
    Location
    London
    MS-Off Ver
    Office 13
    Posts
    20

    Re: Nested IF conditional on many cells...

    Quote Originally Posted by Jonmo1 View Post
    Is it a situation where 'Value x' will be filled incrimentally from the top down?

    i.e., C25 will never equal 'value x' if C21:C24 do not already equal 'value x' ??
    Hi, I wouldn't have thought it necessary to account for this, but they aren't necessarily filled incrementally. Only if each (all) of the cells in the range C21:C25 match the specified value, no matter in what order they are input then should display 'Statement A'. If one of the values is missing (up until they are all input), then it should display 'Statement D'

    Regards

  6. #6
    Forum Guru Jonmo1's Avatar
    Join Date
    03-08-2013
    Location
    Bryan, TX
    MS-Off Ver
    Excel 2010
    Posts
    9,763

    Re: Nested IF conditional on many cells...

    It wasn't 'necessary' to account for that.
    But it would have made the formula much easier if it was true..

    Here's a brute force method, there may be easier more elegant way.

    =IF(COUNTIF(C21:C33,"Value x")=13,"Statement C",IF(COUNTIF(C21:C31,"Value x")=11,"Statement B",IF(COUNTIF(C21:C28,"Value x")=8,"Statement A","Statement D")))

  7. #7
    Administrator FDibbins's Avatar
    Join Date
    12-29-2011
    Location
    Duncansville, PA USA
    MS-Off Ver
    Excel 7/10/13/16/365 (PC ver 2310)
    Posts
    53,049

    Re: Nested IF conditional on many cells...

    It might be easier to understand what you want if you could upload a small (clean) sample workbook (not a pic) of what you are working with, and what your expected outcome would look like.
    1. Use code tags for VBA. [code] Your Code [/code] (or use the # button)
    2. If your question is resolved, mark it SOLVED using the thread tools
    3. Click on the star if you think someone helped you

    Regards
    Ford

  8. #8
    Registered User
    Join Date
    09-27-2015
    Location
    London
    MS-Off Ver
    Office 13
    Posts
    20

    Re: Nested IF conditional on many cells...

    Quote Originally Posted by Jonmo1 View Post
    It wasn't 'necessary' to account for that.
    But it would have made the formula much easier if it was true..

    Here's a brute force method, there may be easier more elegant way.

    =IF(COUNTIF(C21:C33,"Value x")=13,"Statement C",IF(COUNTIF(C21:C31,"Value x")=11,"Statement B",IF(COUNTIF(C21:C28,"Value x")=8,"Statement A","Statement D")))
    Hi there - this works as a fashion, but only because I can substitute '>smallest value' (which happens to be 'value x') although the formula does not include a means of checking that the input values are the correct input values for 'value x' 'value y' and 'value z' as it would if the statement included the actual values, otherwise would display 'Statement D' as a pointer that everything was not as it should be...

    Quote Originally Posted by FDibbins View Post
    It might be easier to understand what you want if you could upload a small (clean) sample workbook (not a pic) of what you are working with, and what your expected outcome would look like.
    Not easy to do as the spreadsheet has many pages each with confidential customer info that I can't really upload. But can basically paste into an otherwise empty excel sheet with cells C21:28 'value x' which is 70, 'value y' which is 80, into cells C29:31, and 'value z' which is 90, into cells C32:33 and run the formula to produce the text string in C34.

    Regards

  9. #9
    Forum Guru Jonmo1's Avatar
    Join Date
    03-08-2013
    Location
    Bryan, TX
    MS-Off Ver
    Excel 2010
    Posts
    9,763

    Re: Nested IF conditional on many cells...

    Yep, I completely missed the x y and z part. Thought it was all x..

    Try
    =IFERROR(INDEX({"C";"B";"A";"A"},MATCH(--(--(COUNTIF(C21:C28,"x")=8)&--(COUNTIF(C29:C31,"y")=3)&--(COUNTIF(C32:C33,"z")=2)),{111;110;100;101},0)),"D")

    Quote Originally Posted by mrexcel27 View Post
    Not easy to do as the spreadsheet has many pages each with confidential customer info
    We don't need to actually see ALL the pages...
    Just the relevant sheet, and make up phony (but similar) information.

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

    Re: Nested IF conditional on many cells...

    Quote Originally Posted by mrexcel27 View Post
    They are numbers, but I'd like it not to matter if they are text strings, as I'd like to adapt this worksheet in the future for other purposes.
    If the variables are TEXT strings then they must be double quoted within the formula. If they are numbers they do not need to be quoted.

    This array formula**:

    =IF(AND(C21:C28="value x",C29:C31="value y",C32:C33="value z"),"Statement C",IF(AND(C21:C28="value x",C29:C31="value y"),"Statement B",IF(AND(C21:C28="value x"),"Statement A","Statement D")))

    ** array formulas need to be entered using the key
    combination of CTRL,SHIFT,ENTER (not just ENTER).
    Hold down both the CTRL key and the SHIFT key
    then hit ENTER.

  11. #11
    Registered User
    Join Date
    09-27-2015
    Location
    London
    MS-Off Ver
    Office 13
    Posts
    20

    Re: Nested IF conditional on many cells...

    Hi Tony, many thanks for this...

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

    Re: Nested IF conditional on many cells...

    You're welcome. Thanks for the feedback!


    If your question has been solved please mark the thread as being solved.

    In the menu bar above the very first post select Thread Tools, then select Mark this thread as solved.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Conditional MAX (nested IF) function?
    By R.Koenig in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 03-19-2012, 11:01 AM
  2. Conditional Formatting with nested IFs
    By yousafkhan1976 in forum Excel General
    Replies: 4
    Last Post: 03-15-2011, 09:37 PM
  3. Nested/Conditional IF statement
    By opsman in forum Excel General
    Replies: 10
    Last Post: 02-05-2010, 03:16 PM
  4. Nested conditional SUMIF?
    By NovaGirl414 in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 07-09-2007, 10:49 PM
  5. Nested conditional statements
    By Apel in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 10-12-2006, 01:28 PM
  6. CONDITIONAL / NESTED COUNTIF
    By OrlandoFreeman in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 07-01-2006, 08:10 PM
  7. Nested ifs and conditional population
    By TJW JR in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 01-19-2006, 12:00 PM
  8. Conditional nested if
    By aijihz in forum Excel General
    Replies: 0
    Last Post: 03-09-2005, 10:33 PM

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