' 遍历每一行
For i = 2 To lastRow
answer = Trim(Cells(i, 5).Value) ' E列答案
If answer "" Then
' 检查每个选项的首字母是否匹配答案
If Left(Cells(i, 2).Value, 1) = answer Then Cells(i, 2).Font.Color = vbRed
If Left(Cells(i, 3).Value, 1) = answer Then Cells(i, 3).Font.Color = vbRed
If Left(Cells(i, 4).Value, 1) = answer Then Cells(i, 4).Font.Color = vbRed
If Left(Cells(i, 5).Value, 1) = answer Then Cells(i, 5).Font.Color = vbRed
End If
Next i
End Sub
测试完美运行
使用方法​​:
按 Alt + F11打开VBA编辑器
在左侧项目资源管理器右键 → 插入 → 模块
粘贴上述代码
按 F5运行,或回到Excel中按 Alt + F8选择宏运行