title: Compare two columns if another two columns are matching in excel macro
body: <p>I want to compare two columns in excel if another two columns are matching.</p>
  
  <pre><code>A          B            C            D
  $10      1234D          $40          100D
  $20      1235D          $10          1234D 
  $30       122D          $20          1235D 
  $40      1222D          $30          1222D 
  </code></pre>
  
  <p>First I need to compare col A and C If any matches find in col C then I need to compare B and D are matching. Example I have $10 in A and its ID is 1234D.i need to compare the same value in C. If I found $10 in C but its id is not 1234D I need to show that un matching one in another column.</p>
  
  <p>I can match A and C as below .but I'm confusing on how to compare B and D after that?i'm new to excel vba and appreciate if any one help me to do this.</p>
  
  <pre><code>  Function Find_Matches()
    Dim CompareRange As Variant, SelectionRange As Variant, x As Variant, y As Variant
      ' compare the selection.
       Sheets("Menu").Activate
      Set SelectionRange = Range("A2:A6")
      Set CompareRange = Range("C2:C6")
  
      ' Loop through each cell in the selection and compare it to
      ' each cell in CompareRange.
      For Each x In SelectionRange
          For Each y In CompareRange
              If x = y Then x.Offset(0, 4) = True
  
          Next y
      Next x
  
  End Function
  </code></pre>