title: Using an AND in VBA
body: <p>I have a worksheet that is used to enter data that is then transferred to a log on a second sheet. </p>
  
  <p>I want to have an if statement in place that stops people from doing duplicate updates. Currently I have a code that stops it updating if one cell is the same as the corresponding last cell of the log but I want to repeat this with 1 or 2 more cells in case the usual 'matching' cell needs to be the same for any reason. </p>
  
  <p>I'm new to VBA, i've tried to play about with <code>else if</code>else if and <code>and</code> but had no luck, I think I am maybe struggling with the structure of these though.  </p>
  
  <p>My <code>And</code> would need to go after the first if statement so if the first statement is false the second one will be true to stop the log from being updated. </p>
  
  <pre><code>Dim WkBk    As Workbook
  Dim WkSht   As Worksheet
  
   Set WkBk = ThisWorkbook
  
  
  Set WkSht = WkBk.Worksheets("Log")
  
  
      If (WkBk.Worksheets("Data").Range("I17") = WkSht.Range("N" &amp; WkSht.Rows.Count).End(xlUp)) Then 
  
  
             MsgBox "This entry has already been logged"
  
  Set WkSht = Nothing
  Set WkBk = Nothing
  Exit Sub
  End If
  </code></pre>