我在同一个工作簿中有两个工作表。第一个工作表包含最后一个时期的得分矩阵,第二个工作表包含这个时期的得分矩阵。
我正在努力寻找一个方法来突出显示此期间工作表中与上一期间工作表不同的那些单元格。
我已经能够识别更改的单元格。我知道使用“MsgBoxes”可以工作,但是我找不到突出显示已识别单元格的方法。可能是因为我选择了完全错误的方式。有人可以给我一个指导我应该如何去做吗?
我拥有的代码(根据 MsgBox 的无论如何)如下。我将非常感谢任何指导。谢谢,
Option Explicit
Sub B_HighlightDifferences()
'Workbooks("Scoring Matrix NEW").Activate
Dim varScoring As Variant
Dim varScoring_OLD As Variant
Dim strRangeToCheck As String
Dim irow As Long
Dim icol As Long
Dim color As CellFormat
strRangeToCheck = "bl9:bo15" 'smallrange for testing purposes only
varScoring = Worksheets("Scoring").Range(strRangeToCheck)
varScoring_OLD = Worksheets("Scoring_OLD").Range(strRangeToCheck)
For irow = LBound(varScoring, 1) To UBound(varScoring, 1)
For icol = LBound(varScoring, 2) To UBound(varScoring, 2)
If varScoring(irow, icol) = varScoring_OLD(irow, icol) Then
' Cells are identical. ' Do nothing.
MsgBox "This has not changed"
Else
' Cells are different.
' Need code here to highlight each cell that is different
MsgBox "This has changed"
End If
End If
Next icol
Next irow
End Sub