title: VBA copy row based on multiple column criteria
body: <p>I am trying to code a row search based on multiple criteria, that will then copy rows which match the criteria. Example below.</p>
  
  <pre><code>1         2   3
  B         C   D
  B         D   C
  C         B   D
  C         D   B
  D         B   C
  D         C   B
  </code></pre>
  
  <p>I have written code that will work based on if the criteria in the first column. What I need though is the code to be able to work no matter which column or number of columns has criteria values. (ex. if criteria for column 1 was B and 3 was C it would copy only row BDC, or if the criteria for column 3 was D it would copy both BCD and CBD) My current written code is missing this criteria but I will copy below.</p>
  
  <pre><code>Private Sub listgen()
      Sheets("Segments").Activate
      Dim a As Long
      Dim b As Long
      Dim c As Long 'columns
      Dim d As Long
      Dim e As Long
      Dim r As Long 'rows
      Dim tr As Long 'total rows
  
      r = 3
      a = 1
      c = 3
      tr = Sheets("Trips").Cells(Rows.Count, a).End(xlUp).Row
      e = c + a
  
      Do
      d = a
      b = 8
          If Sheets("Trips").Cells(r, d).Value = Range("E2") Then
          Do
              Sheets("Trips").Cells(r, d).Copy Destination:=Sheets("Segments").Cells(r, b)
              d = d + 1
              b = b + 1
              Loop Until d = e
          End If
      r = r + 1
      Loop Until r = tr
  
  End Sub
  </code></pre>