用宏,如果数据在AB列,从第二行开始:
Sub a() For i = 2 To Cells(Cells.Rows.Count, 1).End(xlUp) If Cells(i, 1) <> Cells(i, 2) Then Range(Cells(i, 1), Cells(i, 2)).Font.Color = -16776961 End If Next iEnd Sub
采用条件格式,设置单元格值“不等于”就可以了