Private Sub Worksheet_SelectionChange(ByVal Target As Range)
On Error Resume Next
Cells.FormatConditions.Delete
With Target.Cells.FormatConditions
.Delete
.Add xlExpression, , "TRUE"
.Item(1).Interior.Color = RGB(255, 255, 255)'选中单元格颜色
End With
Target.Parent.Cells.Interior.ColorIndex = xlNone
Target.EntireRow.Interior.Color = RGB(253, 233, 217) '行颜色
Target.EntireColumn.Interior.Color = RGB(253, 233, 217)'列颜色
End Sub
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Cells.FormatConditions.Delete
Call fc_exp(Target.EntireRow)
Call fc_exp(Target.EntireColumn)
Target.FormatConditions.Delete
End Sub
'条件格式-表达式
Sub fc_exp(rng As Range)
Dim fc As FormatCondition
Set fc = rng.FormatConditions.Add(Type:=xlExpression, Formula1:=True)
fc.Interior.Color = RGB(253, 233, 217)
End Sub