Jambi46n2
Active Member
- Joined
- May 24, 2016
- Messages
- 260
- Office Version
- 365
- Platform
- Windows
Hello,
I have an existing code I use that works nicely.
Basically if I have two "identical" sheets. Lets say Sheet 1 and Sheet 2.
Sheet 1 may have a cell missing data that doesn't match the same area in Sheet 2.
This code will compare both sheets on a cell level,
then highlight the discrepancies with a message box letting you know how many discrepancies there are.
The only problem I have with this code, is if a row is missing it will highlight everything below that row as a discrepancy.
Is there a way to make this code check for missing rows as well?
Thank you!
I have an existing code I use that works nicely.
Basically if I have two "identical" sheets. Lets say Sheet 1 and Sheet 2.
Sheet 1 may have a cell missing data that doesn't match the same area in Sheet 2.
This code will compare both sheets on a cell level,
then highlight the discrepancies with a message box letting you know how many discrepancies there are.
The only problem I have with this code, is if a row is missing it will highlight everything below that row as a discrepancy.
Is there a way to make this code check for missing rows as well?
Thank you!
Code:
Sub QC_Check()
If MsgBox("Highlight Discrepancies Between Sheet1 and Sheet2?", vbYesNo) = vbNo Then Exit Sub
'Check For Discrepancies and Highlight
' C is Cell Comparison
' Solve for X to identify discrepancies
Dim x As Long
x = 0
Dim c As Range
Sheets(1).Select
Cells.Select
Selection.Columns.AutoFit
With Selection.Interior
.Pattern = xlNone
.TintAndShade = 0
.PatternTintAndShade = 0
End With
Sheets(2).Select
Cells.Select
Selection.Columns.AutoFit
With Selection.Interior
.Pattern = xlNone
.TintAndShade = 0
.PatternTintAndShade = 0
End With
Sheets(1).Select
For Each c In Sheets(1).UsedRange
If c.Text <> Sheets(2).Range(c.Address).Text Then
c.Interior.Color = vbYellow
x = x + 1
End If
Next c
MsgBox "There Are " & x & " Discrepancies"
Last edited: