View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
David David is offline
external usenet poster
 
Posts: 195
Default highlight of a range

David wrote

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Range("I5:S55").FormatConditions.Delete
If Intersect(Target, Range("I5:S55")) Is Nothing Then Exit Sub
With Range(Cells(Target.Row, 9), Cells(Target.Row, 19))
.FormatConditions.Add Type:=xlExpression, Formula1:="TRUE"
.FormatConditions(1).Interior.ColorIndex = 6
End With
End Sub


Was able to reduce to this:
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Range("I5:S55").Interior.ColorIndex = 2
If Intersect(Target, Range("I5:S55")) Is Nothing Then Exit Sub
Range(Cells(Target.Row, 9), Cells(Target.Row, 19)).Interior.ColorIndex = 6
End Sub

Works as desired.

--
David