Hello
I have two spreadsheets that I need to compare and identify any differences. I was using the below macro however, this macro didn't account for any new items was add each quarter. I need help writing a macro that will compare the spreadsheets, highlight and skip to the line if not found and continue search.
Sub RunCompare()
Call compareSheets("Before", "After")
End Sub
Sub compareSheets(shtBefore As String, shtAfter As String)
Dim mycell As Range
Dim mydiffs As Integer
For Each mycell In ActiveWorkbook.Worksheets(shtAfter).UsedRange
If Not mycell.Value = ActiveWorkbook.Worksheets(shtBefore).Cells(mycell.row, mycell.Column).Value Then
mycell.Interior.Color = vbYellow
mydiffs = mydiffs + 1
End If
Next
MsgBox mydiffs & " differences found", vbInformation
ActiveWorkbook.Sheets(shtAfter).Select
End Sub
I have two spreadsheets that I need to compare and identify any differences. I was using the below macro however, this macro didn't account for any new items was add each quarter. I need help writing a macro that will compare the spreadsheets, highlight and skip to the line if not found and continue search.
Sub RunCompare()
Call compareSheets("Before", "After")
End Sub
Sub compareSheets(shtBefore As String, shtAfter As String)
Dim mycell As Range
Dim mydiffs As Integer
For Each mycell In ActiveWorkbook.Worksheets(shtAfter).UsedRange
If Not mycell.Value = ActiveWorkbook.Worksheets(shtBefore).Cells(mycell.row, mycell.Column).Value Then
mycell.Interior.Color = vbYellow
mydiffs = mydiffs + 1
End If
Next
MsgBox mydiffs & " differences found", vbInformation
ActiveWorkbook.Sheets(shtAfter).Select
End Sub