I have the following code that I need to modify to count the cell only if it is 3 or above and the value of the cell would be value -2. Maybe some kind of lookup function with the following table?
0 0
1 0
2 0
3 1
4 2
5 3
6 4
This modified value would be for all cells in the offset. Then when the value of the original cell is greater than 4 the offset becomes 1 to 6.
Private Sub Worksheet_Change(ByVal Target As Range)
Dim oCell As Range
For Each oCell In Range("H3:IV20") '
If oCell.Value <> "" Then '
myTot = oCell.Value
For i = 1 To 2
myTot = myTot + oCell.Offset(0, -i).Value
Next i
Select Case myTot
Case Is < 3
oCell.Interior.ColorIndex = xlNone
Case Is = 3
oCell.Interior.ColorIndex = 6
Case Is = 4
oCell.Interior.ColorIndex = 45
Case Is = 5
oCell.Interior.ColorIndex = 3
Case Is > 5
oCell.Interior.ColorIndex = 39
End Select '
End If '
Next oCell
End Sub
0 0
1 0
2 0
3 1
4 2
5 3
6 4
This modified value would be for all cells in the offset. Then when the value of the original cell is greater than 4 the offset becomes 1 to 6.
Private Sub Worksheet_Change(ByVal Target As Range)
Dim oCell As Range
For Each oCell In Range("H3:IV20") '
If oCell.Value <> "" Then '
myTot = oCell.Value
For i = 1 To 2
myTot = myTot + oCell.Offset(0, -i).Value
Next i
Select Case myTot
Case Is < 3
oCell.Interior.ColorIndex = xlNone
Case Is = 3
oCell.Interior.ColorIndex = 6
Case Is = 4
oCell.Interior.ColorIndex = 45
Case Is = 5
oCell.Interior.ColorIndex = 3
Case Is > 5
oCell.Interior.ColorIndex = 39
End Select '
End If '
Next oCell
End Sub