[INDENT]I found the code in a post and it is excellent for what I am trying to achieve.
However, in my spreadsheets I only want to compare the first 5 (five) columns.
How can this code be altered to do this?
Any assistance would be most appreciated.
Sub RunCompare()
Call compareSheets(“Sheet1”, “Sheet2″)
End Sub
Sub compareSheets(shtSheet1 As String, shtSheet2 As String)
Dim mycell As Range
Dim mydiffs As Integer
‘For each cell in sheet2 that is not the same in Sheet1, color it yellow
For Each mycell In ActiveWorkbook.Worksheets(shtSheet2).UsedRange
If Not mycell.Value = ActiveWorkbook.Worksheets(shtSheet1).Cells(mycell.Row, mycell.Column).Value Then
mycell.Interior.Color = vbYellow
mydiffs = mydiffs + 1
End If
Next
‘Display a message box to demonstrate the differences
MsgBox mydiffs & ” differences found”, vbInformation
ActiveWorkbook.Sheets(shtSheet2).Select
End Sub
[/INDENT]