Formula help

MESTeacher

New Member
Joined
Nov 21, 2024
Messages
1
Office Version
  1. 2016
Platform
  1. Windows
I have a worksheet with student's weekly progress monitoring scores. I have set up conditional formatting for blank cells to remain unformatted and for the cells to be compared to the goal score and turn blue if equal to or greater than. I want to set up conditional formatting where for example this weeks score will be compared to last weeks score and will be green if greater, yellow if equal and red if lower than. I know I can do this with this formula =OFFSET(INDIRECT(ADDRESS(ROW(), COLUMN())),0,-1) My problem is blank cells. If a student is absent, I want it to skip the blank cell(s) and compare it to the last non blank cell to the left. I have uploaded an example of what I have so far.

Sample Sheet.xlsx
ABCDEFGHIJKLMNOPQRSTUVW
1Progress Monitoring Scores 2024-25Aug-12Aug-19Aug-26Sep-2Sep-9Sep-16Sep-23Sep-30Oct-7Oct-14Oct-21Oct-28Nov-4Nov-11Nov-18Nov-25Dec-2Dec-9Dec-16
2GradeStudentPM Test GoalWk 1Wk 2Wk 3Wk 4Wk 5Wk 6Wk 7Wk 8Wk 9Wk 10Wk 11Wk 12Wk 13Wk 14Wk 15Wk 16Wk 17Wk 18Wk 19
31Student 1MFF-1D14771081311111188171117
4NCF-P29891114121717171420131820
51Student 2MFF-1D14739699111011111211
6NCF-P298915172017212421222223
71Student 3MFF-1D1434437686910101310
8NCF-P2878897913131115141518
91Student 4MFF-1D1474771078971012
10NCF-P291722222326252525262727
111Student 5MFF-1D13316677544
12NCF-P31111717161816222122
PM
Cells with Conditional Formatting
CellConditionCell FormatStop If True
E3:W14Cellcontains a blank value textYES
E3:W14Cell Value>=$D3textYES
 

Excel Facts

Square and cube roots
The =SQRT(25) is a square root. For a cube root, use =125^(1/3). For a fourth root, use =625^(1/4).
I suggest you do that via macro. For example:
VBA Code:
Sub CkProgr()
Dim wArea As Range, I As Long, J As Long
Dim Prev As Long
'
Set wArea = Range("A1").CurrentRegion.Offset(2, 4)
For I = 1 To wArea.Rows.Count - 2
    Prev = 0
    For J = 1 To wArea.Columns.Count - 4
        wArea.Cells(I, J).Interior.ColorIndex = xlNone
        If wArea.Cells(I, J).Value <> "" And Prev > 0 Then
            If wArea.Cells(I, J).Value > Prev Then
                wArea.Cells(I, J).Interior.Color = RGB(100, 255, 100)
            ElseIf wArea.Cells(I, J).Value < Prev Then
                wArea.Cells(I, J).Interior.Color = RGB(255, 100, 100)
            ElseIf wArea.Cells(I, J).Value = Prev Then
                wArea.Cells(I, J).Interior.Color = RGB(255, 255, 100)
            End If
        End If
        If wArea.Cells(I, J).Value <> "" Then Prev = wArea.Cells(I, J).Value
    Next J
Next I
End Sub

Copy this code into a Standard Module of your vba project; then run Sub CkProgr when you wish to mark the situation; from Excel, press Alt-F8, select CkProgr from the list of available macros, press the Run button.

You can use the following similar macro to check against the Goal:
VBA Code:
Sub CkGoal()
Dim wArea As Range, I As Long, J As Long
Dim Prev As Long
'
Set wArea = Range("A1").CurrentRegion.Offset(2, 4)
For I = 1 To wArea.Rows.Count - 2
    Prev = wArea.Cells(I, 0).Value
    For J = 1 To wArea.Columns.Count - 4
        wArea.Cells(I, J).Interior.ColorIndex = xlNone
        If wArea.Cells(I, J).Value >= Prev Then
                wArea.Cells(I, J).Interior.Color = RGB(100, 100, 255)
        End If
    Next J
Next I
End Sub

Then run Sub CkGoal when you wish to check for the situation
 
Upvote 0
Welcome to the MrExcel board!

I want to set up conditional formatting where for example this weeks score will be compared to last weeks score and will be green if greater, yellow if equal and red if lower than. ... My problem is blank cells. If a student is absent, I want it to skip the blank cell(s) and compare it to the last non blank cell to the left.
That should be fine with standard Conditional Formatting. Since there is nothing to compare to for Wk 1 my CF starts at Wk 2
Where I have 9^9 in my formulas, that just needs to be any number that will be greater than any possible number in the range. So, you can leave it as it is or perhaps 100 might be big enough?
What I wasn't sure about was if this had to fit in with the blue and if so how?
For example, Cell P3 is above the goal so perhaps blue?, but it is also greater than O3 so perhaps green?
So my suggestion is just for the green/yellow/red options. Clarification required if the blue is to be included.

24 11 22.xlsm
EFGHIJKLMNOPQRSTUVW
2Wk 1Wk 2Wk 3Wk 4Wk 5Wk 6Wk 7Wk 8Wk 9Wk 10Wk 11Wk 12Wk 13Wk 14Wk 15Wk 16Wk 17Wk 18Wk 19
3771081311111188171117
4891114121717171420131820
5739699111011111211
68915172017212421222223
734437686910101310
878897913131115141518
974771078971012
101722222326252525262727
11316677544
12111717161816222122
Compare with last
Cells with Conditional Formatting
CellConditionCell FormatStop If True
F3:W12Expression=AND(F3<>"",COUNT($E3:E3),F3<LOOKUP(9^9,$E3:E3))textNO
F3:W12Expression=AND(F3<>"",COUNT($E3:E3),F3=LOOKUP(9^9,$E3:E3))textNO
F3:W12Expression=AND(F3<>"",COUNT($E3:E3),F3>LOOKUP(9^9,$E3:E3))textNO



Edit:
If you did want to apply the CF to the entire range, including Wk1, for consistency then ..

24 11 22.xlsm
DEFGHIJKLMNOPQRSTUVW
2GoalWk 1Wk 2Wk 3Wk 4Wk 5Wk 6Wk 7Wk 8Wk 9Wk 10Wk 11Wk 12Wk 13Wk 14Wk 15Wk 16Wk 17Wk 18Wk 19
314771081311111188171117
429891114121717171420131820
514739699111011111211
6298915172017212421222223
71434437686910101310
82878897913131115141518
91474771078971012
10291722222326252525262727
1113316677544
1231111717161816222122
Compare with last (2)
Cells with Conditional Formatting
CellConditionCell FormatStop If True
E3:W12Expression=AND(E3<>"",COUNT($E3:E3)>1,E3<LOOKUP(9^9,$D3:D3))textNO
E3:W12Expression=AND(E3<>"",COUNT($E3:E3)>1,E3=LOOKUP(9^9,$D3:D3))textNO
E3:W12Expression=AND(E3<>"",COUNT($E3:E3)>1,E3>LOOKUP(9^9,$D3:D3))textNO
 
Last edited:
Upvote 0

Forum statistics

Threads
1,223,992
Messages
6,175,825
Members
452,672
Latest member
missbanana

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