Excel - Select closest cells & condition

时间:2016-04-04 17:51:56

标签: excel

I have a table that consists of 3 rows:

  1. Student
  2. Subject
  3. Mark

Every student is tested on different subjects, and his marks are written in the table.

In the "Mark" row, the cells' values are numeric. The marks can go between 1 to 100.

I want to look at each student's 3 last marks (regardless of the subject), and see whether there are 2 marks that are above 80. If positive, return true; If not - false;

For example:

  1. Student | John | George | John | John
  2. Subject | Math | English | Literature | Biology
  3. Mark | 100 | 78 | 90 | 92

-> returns true for John

But:

  1. Student | John | George | John | John
  2. Subject | Math | English | Literature | Biology
  3. Mark | 0 | 78 | 90 | 92

-> returns false for John

Thanks!

1 个答案:

答案 0 :(得分:0)

You can use the COUNTIFS function to check this.

If your marks are entered chronologically right to left, you can enter this formula in Cell A4 to flag if the Mark is in the last three (you will need to fill this formula right for all of your columsn):

=COUNTIFS($A$1:A1,A1)<4

If your marks are entered chronologically left to right, you can enter this formula in Cell A4 to flag if the Mark is in the last three (you will need to fill this formula right for all of your columsn):

=COUNTIFS(INDIRECT(CELL("address",A1)&":"&ADDRESS(1,COUNTA(1:1))),A1)<4

And then for each student, you could use this formula:

=COUNTIFS(1:1,"John",3:3,">80",4:4,TRUE)

If you had a list of the student names starting in Cell F1, you could use the formula below and fill down:

=COUNTIFS($1:$1,F1,$3:$3,">80",$4:$4,TRUE)

Edit: included variations for Marks entered left to right and right to left.