Hi all,
The code below compares a row in wb1 with another row in wb2 for differences and returns a msgbox with OK or NOT OK.
Instead of comparing just one row I would like to compare the rest of the two tables with range of A2:F300, is this possible with an adaptation of the below code please?
Thanks!
The code below compares a row in wb1 with another row in wb2 for differences and returns a msgbox with OK or NOT OK.
Instead of comparing just one row I would like to compare the rest of the two tables with range of A2:F300, is this possible with an adaptation of the below code please?
Thanks!
VBA Code:
Sub Compare()
Dim test1 As Variant, test2 As Variant
Dim wb1 As Workbook, wb2 As Workbook
Dim destSht As Worksheet, shSet As Worksheet
Set wb1 = ThisWorkbook
Set wb2 = Workbooks.Open("H:\Project\Structure\Table\Staff List.xlsb")
Set destSht = wb2.Worksheets("Staff_List")
Set shSet = wb1.Worksheets("Table")
destSht.Unprotect "password1"
test1 = Join(Application.Index(destSht.Range("A2:F2").Value, 1, 0), "|")
test2 = Join(Application.Index(shSet.Range("A2:F2").Value, 1, 0), "|")
If test1 = test2 Then
MsgBox "OK"
Else
MsgBox "Not OK"
End If
destSht.Protect "password1"
destSht.Parent.Close True
ThisWorkbook.Activate
End Sub