title: vba-excel: how to exclude copying a range of cells with for loop and if statement
body: <p>I have this code:</p>
  
  <p><pre><code>
  lr = Sheet1.Cells(Rows.Count, 1).End(xlUp).Row</p>
  
  <p>For a = 1 To lr
      If (Sheet1.Cells(a, 1) = Date Or Date - 1) And (Sheet1.Cells(a, 2) = "AA" Or Sheet1.Cells(a, 2) = "BB" Or Sheet1.Cells(a, 2) = "CC") And Sheet1.Cells(a, 3) = array(0) Then
          Call ActivateSheet
          Sheet1.Range(Cells(a, 4), Cells(a, 10)).Copy
          Sheet2.Cells(Rows.Count, 1).End(xlUp).Offset(1, 0).PasteSpecial
      End If
  Next a</pre></code></p>
  
  <p>I have two columns with data in them. In column <strong>A</strong> we have there the value of DATE which i'll call <strong>currentDate</strong> and the value of DATE-1 which i'll call <strong>yesterDate</strong>. In column <strong>B</strong> I could have <strong>three</strong> different values, which are <strong>AA</strong>, <strong>BB</strong>, and <strong>CC</strong>. My if statement above (i apologize for how noobish the code looks, i'm still trying to learn VBA. ;P) basically checks if the values in column <strong>A</strong> are either the <strong>currentDate OR yesterDate</strong> and checks if the values in column <strong>B</strong> are either <strong>AA</strong>, <strong>BB</strong>, OR <strong>CC</strong>. THEN, if the values of column <strong>A</strong> and column <strong>B</strong> are any combinations of the given values, it will copy that range of cells and paste it on <strong>Sheet2</strong>. </p>
  
  <p>So here's what I want to happen. From all the possible combinations of the values given, there's one combination <strong>I don't want to copy</strong> and that combination is <strong>yesterDate &amp;&amp; CC</strong>. </p>
  
  <p>I only want my code to copy <strong>yesterDate &amp;&amp; AA</strong>, and <strong>yesterDate &amp;&amp; BB</strong>, and <strong>currentDate &amp;&amp; CC</strong>. All other combinations like <strong>currentDate &amp;&amp; AA or currentDate &amp;&amp; BB</strong> will not likely to happen based from the user input. </p>
  
  <p>I just want to exclude <strong>yesterDate &amp;&amp; CC</strong> to be copied by my code. Any ideas on how I can achieve this?  </p>