title: Copy a specific range of rows once conditions are met and paste it to another sheet
body: <p>I have two worksheets:<br />
  Sheet1 - &quot;raw&quot;<br />
  Sheet2 - &quot;copy&quot;</p>
  <p>The button that has the macro code is in Sheet2. Once I click the button, the macro will run with the first condition that if cell B2 in Sheet1 has a value, it should copy row B2:X2 and paste it to the second row (after the header) of Sheet2. But if no value, it should loop to the next row and repeat the operation.</p>
  <p>The condition I'm having trouble with adding, is as follows:<br />
  If cell X2 is equal to 'Yes', it should copy row B2:M2 and row range Y2:AH2 of Sheet1 then paste it to range B3:N3 of Sheet2 and O3:X3 of Sheet2. This same goes for row AI2, AT2, BE2, BP2, and CA2 wherein values contain Yes or No. But if the answer is 'No' or has no value, it will loop on the next row in Sheet1 then run again the same copy method until the last row. But it shouldnt copy a blank row.</p>
  <p>Below is the current code for the first condition.</p>
  <pre class="lang-vb prettyprint-override"><code>Sub Copy3()
  
      Dim srcws As Worksheet
      Dim destws As Worksheet
  
      Set srcws = Worksheets(&quot;raw&quot;)
      Set destws = Worksheets(&quot;copy&quot;)
      
      srcws.Select
      SecondRow = Cells(Rows.Count, 1).End(xlUp).Row
      
      For i = 2 To SecondRow
          ThisValue = Cells(i, 2).Value
          If ThisValue &lt;&gt; &quot; &quot; Then
              srcws.Range(&quot;B&quot; &amp; i &amp; &quot;:W&quot; &amp; i).Copy _
                  Destination:=destws.Range(&quot;B&quot; &amp; i)
          End If
      Next i
      
      Application.ScreenUpdating = True
  
  End Sub
  </code></pre>
  <p>This is somehow working though i dont want to copy blank rows only those have values on cell B2.</p>
  <p>Any help will be appreciated for this to work!</p>
  <p>For the Second condition - If cell X2 is equal to 'Yes', then it will copy range B2:M2 and range Y2:AH2 from Sheet1 to next row of Sheet2 which is under the row of copied data from first condition.</p>
  <p>Basically because every row has the employee data and first employee dependent from range B2:W2 of Sheet1 then every row cell of X (Sheet1) contains value of 'Yes' or 'No'. That if row X2 value is Yes, it should copy the employee details from Sheet1 range B2:M2 and paste it to range B3:N3 of Sheet2. Then copy range Y2:AH2 from Sheet1 and paste it to range O3:X3 of Sheet2</p>
  <p>I hope this will help explain the second condition. Though i dont have the code yet created for this.</p>
  <p>Thank you!</p>
  <p>Condition 2:
  If cell X = Yes, then copy range B:M from Sheet1 and paste it to next row range B:N of Sheet2 and copy range Y:AH of Sheet1 and paste it to next row range O:X of Sheet2
  But if No, go to next row of Sheet1 and apply condition 1</p>
  <p>Condition 3:
  If cell AI = Yes then copy range B:M from Sheet1 and paste it to next row range B:N of Sheet2 and copy range AJ:AS of Sheet1 and paste it to next row range O:X of Sheet2</p>
  <p>Condition 4:
  If cell AT = Yes then copy range B:M from Sheet1 and paste it to next row range B:N of Sheet2 and copy range AU:BD of Sheet1 and paste it to next row range O:X of Sheet2</p>
  <p>Condition 5:
  If cell BE = Yes then copy range B:M from Sheet1 and paste it to next row range B:N of Sheet2 and copy range BF:BO of Sheet1 and paste it to next row range O:X of Sheet2</p>
  <p>Condition 6:
  If cell BP = Yes then copy range B:M from Sheet1 and paste it to next row range B:N of Sheet2 and copy range BQ:BZ of Sheet1 and paste it to next row range O:X of Sheet2</p>
  <p>Sorry for the confusion but let me know for any details needed.</p>