Hello LarryC,
Here is the revised macro. When using event macros that change worksheet values be sure to disable further events and re-enable them when you code has finished.
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Dim cell As Range
Dim formulacells As Range
Const REDINDEX = 3
Const GREENINDEX = 4
Application.ScreenUpdating = False
Application.EnableEvents = False
On Error Resume Next
'create subsets of original selection
Set formulacells = Selection.SpecialCells(xlFormulas, xlNumbers)
If Err.Number <> 0 Then Err.Clear
On Error GoTo 0
'Process the formula cells
If Not formulacells Is Nothing Then
For Each cell In formulacells
If cell.Value = 1 Then
cell.Interior.ColorIndex = GREENINDEX
ElseIf cell.Value < 1 Then
cell.Interior.ColorIndex = REDINDEX
Else
cell.Interior.ColorIndex = xlNone
End If
Next cell
End If
Application.EnableEvents = True
End Sub
Sincerely,
Leith Ross
Bookmarks