title: VBA if cells on sheet 1 match cells on sheet 2 - delete row?
body: <p>I have two worksheets, sheet 1 and sheet 2.</p>
  
  <p>On sheet 1 I have created a form which allows users to enter values into cells B21, B26, I21, I26, P21, P26.</p>
  
  <p>Then by clicking submit, the data gets inserted onto sheet 2 in columns A,B,C,D,E and F on the next available row.</p>
  
  <p>I am also trying to create a macro that once run, will delete the row on sheet 2 where the values match those on sheet1.</p>
  
  <p>At the moment i am keeping it simple by using an IF statement, but this gives me a type mismatch error.</p>
  
  <pre><code>Sub QuickCull()
  
  If Sheets(1).Range("B21").Value = Sheets(2).Range("A:A").Value And _
      Sheets(1).Range("B26").Value = Sheets(2).Range("B:B").Value And _
      Sheets(1).Range("P21").Value = Sheets(2).Range("C:C").Value And _ 
      Sheets(1).Range("I21").Value = Sheets(2).Range("D:D").Value And _
      Sheets(1).Range("I26").Value = Sheets(2).Range("E:E").Value And _
      Sheets(1).Range("P26").Value = Sheets(2).Range("F:F").Value Then
  
      Rows(ActiveCell.Row).EntireRow.Delete
  End If
  
  End Sub
  </code></pre>
  
  <p>Please can someone show me where i am going wrong? </p>