title: Excel VBA code for matching values and copying whole row
body: <p>So I am extremely new to VBA but have to finish a project that requires sorting some data. I have two sheets. One sheet( called 'values') has a single column of values that I need to test if a value matches at least one of the 5 columns of a record (row) in another very large sheet ('sheet1'), and copy the whole record (row) to a second spreadsheet ('sheet2).</p>
  
  <p>This is my pseudo code: </p>
  
  <pre><code>for each row in sheet1 where sheet1.row = A1:Q1231231
  for each value in values  where values.value = b1:b300
      for each col (e1:j1) where sheet1.col = E-rownum : J-rownum
          if value == col-value 
              copy row to sheet2
              break, esc value 
  Next row
  </code></pre>
  
  <p>And this is what i have so far, but i'm a little stuck on whether im referencing everything correctly. How do i just obtain columns E:J for each row when I need to match the values against those cells only? How do I copy the entire row if there is a match, and to immediately break and move on to the next record?</p>
  
  <pre><code>Private Sub CommandButton1_Click()
  
      Dim sheetrow As Range
      Dim Values As Range
      Dim cells As Range
  
      Set Sheet1 = Worksheets("Sheet1")
      Set Values = Worksheets("values").Rows("B2:B330")
      Set Sheet2 = Worksheets("Sheet2")
  
  
      For Each sheetrow In Sheet1.Rows
          For Each value In Values
              For Each cell In sheetrow.cells // only need cell cols E:J
                  //if value == cell
                  // copy row to sheet2
                  //break (no need to check the rest of the row if match)
              Next
          Next
      Next
  End Sub
  </code></pre>
  
  <p>Just to inform, this is not for a VBA assignment. This is just a very large amount of data and a script would work better than trying to manually go through it. Thank you so much!</p>