简体   繁体   中英

Excel Conditonal Format between two data sets

I have two data sets on separate sheets.

One is predictive data for pupils by subject The other is actual results data for pupils by subject.

Both datasets have the same structure

Pupil Name, English, Mathematics, Science

John Doe,     7,        8,          9

Peter John,   8,        9,          9

I'd like to compare using conditional formatting whether the pupil got a higher or lower result than the predictive data.

If higher then the colour should be green, if lower then red and no colour change if its the same.

What I'm struggling with is how do I first match the pupil and subject to compare whether there's a difference and then secondly compare the two results to show the difference by colouring the cell I would be grateful for any pointers.

Thanks,

To find the results, you can use an Index/Match combo. Let's say the two sheets are called Predictions and Results . To look up the prediction for the first name, use

INDEX(Predictions:$B$2,$D$5,MATCH($A2:Predictions,$A$2,$A$5,0):MATCH(B$1,Predictions!$B$1:$D$1,0))

Now create a rule that compares that prediction with the result.

  • select all result cells, starting with B2 as the active cell
  • create a rule with a formula, using =B2>INDEX(Predictions:$B$2,$D$5,MATCH($A2:Predictions,$A$2,$A$5,0):MATCH(B$1,Predictions!$B$1:$D$1,0))
  • format with green
  • use the < operator for a second rule for the red format

Note the positioning of the $ signs in the various cell references. A $ sign anchors a reference. A reference like B2 will apply to a different cell when the cell a few rows down and a few columns across is evaluated.

Note that some older versions of Excel do not allow off-sheet conditioning formatting rules. In that case, you need to bring the predictions table to the same sheet as the results.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM