' ****************************************************************
' *** WHEN A VALUE IS CHANGED, THE FOLLOWING CODE IS TRIGGERED ***
' ****************************************************************
Private Sub Worksheet_Change(ByVal Target As Range)
Dim bgcol As Integer
Dim found As Integer
found = 0
Dim avgstr As String
avgstr = ""
For x = 14 To 49
If Cells(Target.Row, x) = "<0.005" Then
found = found + 1
End If
Next x
If found > 0 Then
For x = 1 To found
avgstr = avgstr & ",.0025"
Next x
End If
If Cells(Target.Row, 1).Interior.ColorIndex = -4142 Then
Cells(Target.Row, 50).Formula = "=AVERAGE(N" & Target.Row & ":AW" & Target.Row & avgstr & ")"
If IsError(Cells(Target.Row, 50)) Then
Cells(Target.Row, 50).Formula = "" ' PROGRAM BOMBS
Else
If Cells(Target.Row, 50) >= 1 Then ' If final grade is big
Cells(Target.Row, 50).Font.Bold = True ' Bolden it
Else ' Under 1
Cells(Target.Row, 50).Font.Bold = False ' No boldness
End If
End If
Cells(Target.Row, 50).NumberFormat = "General"
End If
End Sub