使用VBA事件:
VBA编辑框中,点击工作表,输入如下代码。
Private Sub Worksheet_Change(ByVal Target As Range)
Target.Interior.Color = vbRed
End Sub
Dim a, b, c, d, e, f
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
a = Cells(ActiveCell.Row, ActiveCell.Column).Value
b = ActiveCell.Row
c = ActiveCell.Column
If d = "" And e = "" And f = "" Then
d = a
e = b
f = c
Else
If d = Cells(e, f).Value Then
e = b
f = c
Else
Cells(e, f).Font.Color = -16776961
e = b
f = c
End If
End If
d = Cells(e, f).Value
End Sub