比较不同工作表上的相同范围



我有一个工作簿,里面有多张纸(第1张、第2张……等(和一个"大师";床单我需要从列a:C中选择一个范围,直到它遇到一个值为(tva(的行(包括这些行(。我想将Master的范围与其他表进行比较,并强调差异。示例图像例如母版纸具有A3值"0";m〃;。

这就是我到目前为止所拥有的。我是这方面的新手,所以任何建议都很感激:(

Sub comp()
Dim ws As Worksheet
Dim rngCell As Range
For Each ws In ThisWorkbook.Worksheets
ws.Activate
rngCell = Columns("A:C").Resize(Columns("A:C").Find(What:="tva", After:=Range("A1"), LookIn:=xlValues, SearchDirection:=xlPrevious).Row)
rngCell.Select
For Each rngCell In ws.Range
If Not rngCell = Worksheets("Master").Cells(rngCell.Row, rngCell.Column) Then
rngCell.Interior.Color = vbYellow
End If

Next ws


End Sub

您可以尝试以下代码,尽管它没有覆盖其他列,但小的调整只需要检查到C列(第3列(:

Sub comp()
Dim ws As Worksheet
Dim valuerow As Long, irow As Long
For Each ws In ThisWorkbook.Worksheets
ws.Activate
valuerow = Cells.Find(What:="tva", After:=Range("A1"), LookIn:=xlValues, SearchDirection:=xlPrevious).Row
For irow = 1 To valuerow

If ws.Cells(irow, 1).Value <> Worksheets("Master").Cells(irow, 1).Value Then
ws.Cells(irow, 1).Interior.Color = vbYellow
End If

If ws.Cells(irow, 2).Value <> Worksheets("Master").Cells(irow, 2).Value Then
ws.Cells(irow, 2).Interior.Color = vbYellow
End If

Next
Next
End Sub

相关内容

  • 没有找到相关文章

最新更新