Basing calculations on cell colours - possible?

billv84

New Member
Joined
Mar 11, 2023
Messages
8
Office Version
  1. 365
Platform
  1. Windows
Hi all,

Hoping someone with a more powerful brain than me can help solve this problem!

I work in a school. We obviously record pupil progress in core subjects like maths and English in an MIS.
But for other subjects, something far simpler is acceptable.

We are trying to come up with an Excel template where we can have a vertical list of pupil names, then a horizontal list of topics within a subject running across the top.
For each topic, every pupil with be RAG-rated (i.e. red-limited progress, amber-getting there, green-got it).
To reduce teacher workload, we could apply red and amber by exception - i.e. the default is green.

What I'd like to know is if it's possible to have a 'total'-style column, running horizontally underneath the row of topic headers, which will show a percentage (or something similar) to indicate how much of the class have met expectations for that topic (i.e. been graded as green).

I've attached an image with a rough idea of what I'm trying to explain.

Thank you very much in advance for any help!

Bill
 

Attachments

  • Screenshot 2023-03-11 094405.png
    Screenshot 2023-03-11 094405.png
    22.6 KB · Views: 29
Hi,
As another possibility, a simple UDF
VBA Code:
Function mypct(rng As Range)
Dim c As Range, counter As Long
    For Each c In rng
        If c.Interior.Color = 255 Or c.Interior.Color = 49407 Then counter = counter + 1
    Next c
 mypct = Format((rng.Count - counter) / rng.Count, "00%")
End Function

In cell E6, just type =mypct(E7:E16)
 
Upvote 0

Excel Facts

How to fill five years of quarters?
Type 1Q-2023 in a cell. Grab the fill handle and drag down or right. After 4Q-2023, Excel will jump to 1Q-2024. Dash can be any character.
To me, this would be much easier to calculate and just as easy to use if you used your RAG rating in the cell and had conditional formatting apply the colour rather than manually applying colour.

In the sample below, in the conditional formatting I have made the font a slightly different colour to the background so that you can see it but in your actual sheet once you have it working, make the font in the CF exactly the same colour as the background 'Fill' colour and it will look just like your sample.
Start by entering a g (or G) in all the cells (select all cells, type g and confirm all with Ctrl+Enter).
Then if you want to mark a student as amber or red, just type an a or r in the relevant cell.
As you can see, the formula for the % calculation is then pretty simple.

billv84.xlsm
DEFGHIJ
5Topic 1Topic 2Topic 3Topic 4Topic 5Topic 6
660%90%100%10%0%0%
7Lastgggarr
8Lastgggarr
9Lastgggarr
10Lastrggarr
11Lastgggarr
12Lastgggarr
13Lastrggarr
14Lastgggarr
15Lastaggarr
16Lastarggrr
Sheet1
Cell Formulas
RangeFormula
E6:J6E6=COUNTIF(E7:E16,"g")/COUNTA(E7:E16)
Cells with Conditional Formatting
CellConditionCell FormatStop If True
E7:J16Expression=E7="r"textNO
E7:J16Expression=E7="a"textNO
E7:J16Expression=E7="g"textNO
Hi Peter, sorry to be a pain, but I'm struggling to sort out the conditional formatting step here. Would you possibly mind giving me some idiot-proof instructions?! Many thanks!
 
Upvote 0
Hi,
As another possibility, a simple UDF
VBA Code:
Function mypct(rng As Range)
Dim c As Range, counter As Long
    For Each c In rng
        If c.Interior.Color = 255 Or c.Interior.Color = 49407 Then counter = counter + 1
    Next c
 mypct = Format((rng.Count - counter) / rng.Count, "00%")
End Function

In cell E6, just type =mypct(E7:E16)
Thanks James! I have never used this functionality in Excel, but will give it a go! Thanks again for your time
 
Upvote 0
You are welcome :)

Hope this solution is simple enough
 
Last edited:
Upvote 0
I'm struggling to sort out the conditional formatting step here. Would you possibly mind giving me some idiot-proof instructions?!
For the layout shown with the first coloured cell being E7
  1. Select from E7 to bottom right of area to be colored (J16 in the sample)
  2. Home ribbon tab -> Conditional Formatting -> Clear Rules -> Clear Rules from Selected Cells
  3. Home ribbon tab -> Conditional Formatting -> New rule ... -> Use a formula to determine which cells to format -> Format values where this formula is true:- =E7="g" -> Format... -> Fill tab -> Choose green -> Font tab -> Color -> Choose the same green -> OK -> OK
  4. With the cells still selected, repeat step 3 but use the formula =E7="a" and set Fill & Font colour to amber
  5. With the cells still selected, repeat step 3 but use the formula =E7="r" and set Fill & Font colour to red
The important thing is that the cell refence used in the formulas (E7 in this example) is whatever the active cell is in the range selected.

Now, typing "r" or "a" or "g" in one of the cells should set its colour and update the % calculation if the change was to or from green.

A sample workbook with the conditional formatting all set up can be accessed via this link: billv84_1.xlsm
 
Upvote 1
Solution
For the layout shown with the first coloured cell being E7
  1. Select from E7 to bottom right of area to be colored (J16 in the sample)
  2. Home ribbon tab -> Conditional Formatting -> Clear Rules -> Clear Rules from Selected Cells
  3. Home ribbon tab -> Conditional Formatting -> New rule ... -> Use a formula to determine which cells to format -> Format values where this formula is true:- =E7="g" -> Format... -> Fill tab -> Choose green -> Font tab -> Color -> Choose the same green -> OK -> OK
  4. With the cells still selected, repeat step 3 but use the formula =E7="a" and set Fill & Font colour to amber
  5. With the cells still selected, repeat step 3 but use the formula =E7="r" and set Fill & Font colour to red
The important thing is that the cell refence used in the formulas (E7 in this example) is whatever the active cell is in the range selected.

Now, typing "r" or "a" or "g" in one of the cells should set its colour and update the % calculation if the change was to or from green.

A sample workbook with the conditional formatting all set up can be accessed via this link: billv84_1.xlsm
Thank you so much Peter! Really appreciate your time (and patience!) Have a great day, wherever you are and whatever you're doing :)
 
Upvote 0

Forum statistics

Threads
1,224,824
Messages
6,181,186
Members
453,020
Latest member
Mohamed Magdi Tawfiq Emam

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top