这将突出显示列中的第二个单元格。颜色现在可能是您想要的确切颜色。
EDIT2:添加了 testcell1、first、Second 和 Add Report 的定义作为工作表代码
编辑 3:将 <> 更改为 =
Sub runthis()
'Dim row As Integer
Dim TestCell As String
Dim first As String
Dim Second As String
Dim TestCell1 As String
Dim lastcell As Integer
Sheets("sheet1").Select
Dim Report As Worksheet
Set Report = Excel.Worksheets("Sheet1")
lastcell = Sheets("sheet1").Cells(Rows.Count, "A").End(xlUp).row
For row = 1 To lastcell
TestCell = "A" & CInt(row)
TestCell1 = "A" & (CInt(row) + 1)
first = Range(TestCell).Value
Second = Range(TestCell1).Value
If first = Second Then
Report.Cells(row, 1).Interior.ColorIndex = 3
End If
Next row
End Sub