[vba]Originally Posted by blackie42
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Const WS_RANGE As String = "H1:H10" '<== change to suit
On Error GoTo ws_exit
Application.EnableEvents = False
If Target.Cells.Count > 1 Then Exit Sub
If Not Intersect(Target, Me.Range(WS_RANGE)) Is Nothing Then
With Target
.FormatConditions.Delete
.FormatConditions.Add _
Type:=xlExpression, _
Formula1:="=ISERROR(" & .Address(False, False) & ")"
.FormatConditions(1).Interior.ColorIndex = 3 'Red
End With
End If
ws_exit:
Application.EnableEvents = True
End Sub
[/vba]
This is worksheet event code, which means that it needs to be
placed in the appropriate worksheet code module, not a standard
code module. To do this, right-click on the sheet tab, select
the View Code option from the menu, and paste the code in.