+ Reply to Thread
Results 1 to 7 of 7

if statement using multiple cells..

  1. #1
    Registered User
    Join Date
    05-17-2007
    Posts
    5

    Red face if statement using multiple cells..

    I have 4 cells each containing differing values, I need to be able to give a score depending on all of the cell values i.e

    if all 4 individual cells contain the number 2 then "1"
    if all 4 individual cells contain the number 1 then "2"
    if all but 1 cell contains the number 1 then "3"
    if all but 2 cells contains the number 1 then "4"
    if only 1 cell contains the number 1 then "5"

    any ideas - im stumped!
    Last edited by Minx1976; 05-17-2007 at 12:15 PM. Reason: want to change smilie

  2. #2
    Forum Expert daddylonglegs's Avatar
    Join Date
    01-14-2006
    Location
    England
    MS-Off Ver
    2016
    Posts
    14,675
    Assuming your cells are A1:D1

    =IF(COUNTIF(A1:D1,2)=4,1,LOOKUP(COUNTIF(A1:D1,1),{0,1,2,3,4},{"",5,4,3,2}))

  3. #3
    Registered User
    Join Date
    05-17-2007
    Posts
    5
    Thanks for you quick responce, it's not bringing back my required values can you explain to me what the formula is doing?? I can try and amend it then, sorry if I sound dim!!

  4. #4
    Registered User
    Join Date
    05-17-2007
    Posts
    5
    I think I may not have helped myself earlier - this is what im after...

    if all 4 individual cells contain the number 2 then "1"
    if all 4 individual cells contain the number 1 then "2"
    if any one of the cells contain 0 then "3"
    if 2 of the cells contain 0 "4"
    if only 1 cell contains the number 1 or 2 then "5"

  5. #5
    Forum Expert daddylonglegs's Avatar
    Join Date
    01-14-2006
    Location
    England
    MS-Off Ver
    2016
    Posts
    14,675
    OK, so your new conditions aren't mutually exclusive, I presume the order in which they're written determines the order of precedence, e.g. what result do you expect if 2 cells contain a zero and 1 contains a 1? I assume 4

    What result do you expect if one cell is blank and the other 3 contain 1s?

  6. #6
    Registered User
    Join Date
    05-17-2007
    Posts
    5
    Your expectation on the "4" result is correct.

    There would never be a blank cell, however if three cells contain "1" or "2" and the other contains 0 then I would expect "5" to be the result...

  7. #7
    Registered User
    Join Date
    05-17-2007
    Posts
    5
    Daddylonglegs I've done it!!!!

    Thanks for starting me off on the right foot - much appreciated!

    Not sure if this is the most succint way to right what i need but it works so I'll take it.

    =if(COUNTIF(G40:J40,1)=4,2,IF(COUNTIF(G40:J40,2)=4,1,IF(COUNTIF(G40:J40,0)=4,5,IF(COUNTIF(G40:J40,0)=3,5,IF(COUNTIF(G40:J40,0)=2,4,IF(COUNTIF(G40:J40,0)=1,3,IF(COUNTIF(G40:J40,0)=0,2)))))))

    Thanks again

+ 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