Just got a task that there is a database table which got row add / delete / updates and wants to compare and mark out differences in Excel sheets.
Input:
Output:
Steps:
Sub comparesheet()'''''using rstTableSheet (Sheet4) as base for compareFor Each MyCell In Sheet4.UsedRange '''''first reset the cell with white background MyCell.Interior.ColorIndex = 0 Sheet3.Range(MyCell.Address).Interior.ColorIndex = 0 '''''if cell is not empty... If Trim(MyCell.Value) <> "" Then '''''if cells in the same position of those 2 sheets got different values... If Trim(MyCell.Value) <> Trim(Sheet3.Range(MyCell.Address).Value) Then '''''paint both cells background to red MyCell.Interior.ColorIndex = 3 Sheet3.Range(MyCell.Address).Interior.ColorIndex = 3 End If End IfNextEnd Sub
FYI.
Let me know if you got more efficient ways to do this task...