发布网友 发布时间:2022-04-22 13:14
共1个回答
热心网友 时间:2023-10-03 10:09
1. 使用VBA代码实现:
Private Sub Worksheet_SelectionChange(ByVal Target As Range)2. 效果如图所示:
追答Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Dim i As Integer
If Target.Row = 2 And Target.Column = 1 Then
For i = 5 To 15
If Range("A" & i) <> "A" Then
Range("A" & i).Font.Color = RGB(255, 255, 255)
Else
Range("A" & i).Font.Color = RGB(0, 0, 0)
End If
Next i
End If
If Target.Row = 2 And Target.Column = 2 Then
For i = 5 To 15
If Range("A" & i) <> "B" Then
Range("A" & i).Font.Color = RGB(255, 255, 255)
Else
Range("A" & i).Font.Color = RGB(0, 0, 0)
End If
Next i
End If
End Sub
效果如下图所示: