title: Excel marco vba - Checking of 1 and/or 2 cells for values
body: <p>I am new to Excel VBA macro, but I'm tasked to create a project which is to let users input value(s) to the cell(s) in sheet 2, search through the data(sheet 1) and copy paste the filtered data to sheet 2.</p>
  
  <p>Let say A and B are the values inputs. I tried</p>
  
  <pre><code>    For Row = 2 To finalrow
          If Cells(i, 1).value = a And Cells(i, 2).value = b Then
              Range(Cells(i, 1), Cells(i, 7)).Copy
              Sheet2.Select
              Range("A200").End(xlUp).Offset(1, 0).PasteSpecial xlPasteFormulasAndNumberFormats
              Sheet1.Select
          ElseIf Cells(i, 1).Value = A Or Cells(i, 2).Value = B Then
              Execute
          End If
      Next Row
      Sheet2.Select
      Range("B1").Select
      Range("B3").Select
  </code></pre>
  
  <p>If the user input 1 value, the result is correct. But if the user input both A and B, it should return those rows containing the 2 values, but instead it returned me A results and B results.</p>
  
  <p>Thank you in advance.</p>