Public Sub Highlight(ByVal SourceRange As Range, ByVal Target As Range, ByVal ColorIndex As Long, Optional ColorType As Long = 1)
Dim rTmp As Range, rRow As Range, rCol As Range
On Error Resume Next
Set rRow = Target.EntireRow
Set rCol = Target.EntireColumn
SourceRange.FormatConditions.Delete
If Not Intersect(SourceRange, Target) Is Nothing Then
Select Case ColorType
Case 1: Set rTmp = Intersect(SourceRange, rRow)
Case 2: Set rTmp = Intersect(SourceRange, rCol)
Case 3: Set rTmp = Intersect(SourceRange, Union(rRow, rCol))
Case 4: Set rTmp = Intersect(Range(SourceRange.Cells(1, 1), Target), Union(rRow, rCol), SourceRange)
End Select
If Not rTmp Is Nothing Then
If Application.CutCopyMode = False Then
rTmp.FormatConditions.Add 2, , "TRUE"
rTmp.FormatConditions(1).Interior.ColorIndex = ColorIndex
End If
End If
End If
End Sub