用于颜色不匹配数据的VBA代码

时间:2018-03-30 09:48:15

标签: excel vba colors match

我想知道一段代码突出显示单元格值从一张纸1到另一张纸的不同。

例如,在单元格A2(sheet1)中,值为asd24,在单元格A2(sheet2)中,值为asd25,则该特定单元格必须以第1页或第2页中的任何颜色突出显示。

我已经开发了with检查单元格的值:

Sub test()

Dim varSheetA As Variant
Dim varSheetB As Variant
Dim strRangeToCheck As String
Dim iRow As Long
Dim iCol As Long
   Dim R As Range
strRangeToCheck = "A1:IV65536"
' If you know the data will only be in a smaller range, reduce the size of the ranges above.
Debug.Print Now
varSheetA = Worksheets("Sheet1").Range(strRangeToCheck)
varSheetB = Worksheets("Sheet2").Range(strRangeToCheck) ' or whatever your other sheet is.
Debug.Print Now

For iRow = LBound(varSheetA, 1) To UBound(varSheetA, 1)
    For iCol = LBound(varSheetA, 2) To UBound(varSheetA, 2)
        If varSheetA(iRow, iCol) = varSheetB(iRow, iCol) Then
            ' Cells are identical.
            ' Do nothing.
        Else
            **/*/dont know what to do here*** 
        End If
    Next iCol
Next iRow

End Sub

0 个答案:

没有答案