Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Here is a sample. The sample code only records the array(i,j) coordinates of the mismatches in the comparison tab. You should modify it to record any other information you need:</p> <pre><code>Sub CompareSheets() Dim s1 As Worksheet, s2 As Worksheet, s3 As Worksheet Dim rComp As Range, addy As String Dim I As Long, J As Long, K As Long Set s1 = Sheets("Sheet1") Set s2 = Sheets("Sheet2") Set s3 = Sheets("comparison") s1.Select Set rComp = Application.InputBox(Prompt:="Select range", Type:=8) addy = rComp.Address ary1 = rComp ary2 = s2.Range(addy) K = 1 For I = LBound(ary1, 1) To UBound(ary1, 1) For J = LBound(ary1, 2) To UBound(ary1, 2) If ary1(I, J) = ary2(I, J) Then Else s3.Cells(K, 1) = I s3.Cells(K, 2) = J K = K + 1 End If Next J Next I End Sub </code></pre> <p><strong>EDIT:</strong></p> <p>In response to your comment this version will fill the comparison sheet with TRUEs and FALSEs:</p> <pre><code>Sub CompareSheets2() Dim s1 As Worksheet, s2 As Worksheet, s3 As Worksheet Dim rComp As Range, addy As String Dim I As Long, J As Long, K As Long Set s1 = Sheets("Sheet1") Set s2 = Sheets("Sheet2") Set s3 = Sheets("comparison") s1.Select Set rComp = Application.InputBox(Prompt:="Select range", Type:=8) addy = rComp.Address ary1 = rComp ary2 = s2.Range(addy) ary3 = s3.Range(addy) K = 1 For I = LBound(ary1, 1) To UBound(ary1, 1) For J = LBound(ary1, 2) To UBound(ary1, 2) If ary1(I, J) = ary2(I, J) Then ary3(I, J) = "TRUE" Else ary3(I, J) = "FALSE" End If Next J Next I s3.Range(addy) = ary3 End Sub </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload