Excel实现两个工作表数据的对比
Sub 数据对比() Dim i As Integer Dim j As Integer For i = 3 To 12 '员工基础报表数据范围 For j = 3 To 11 '员工待遇统计表数据范围 If Sheets("员工基础报表").Cells(i, 1) = Sheets("员工待遇统计表").Cells(j, 1) Then If Sheets("员工基础报表").Cells(i, 2) = Sheets("员工待遇统计表").Cells(j, 2) Then Sheets("员工基础报表").Cells(i, 8) = "已存在" '存在时进行标记 End If End If Next j Next i End Sub