Macro that copy/pastes rows based on a certain condition on SAME sheet.

Report
-
Posts
2700
Registration date
Sunday September 12, 2010
Status
Moderator
Last seen
February 25, 2021
-
Hello,

I am trying to create a macro that will copy a row with 6 columns on the condition that the 6th column is blank. Then it should paste the rows that meet said condition in another part of the SAME sheet.

Any help is greatly appreciated.


System Configuration: Windows / Chrome 88.0.4324.182

1 reply

Posts
2700
Registration date
Sunday September 12, 2010
Status
Moderator
Last seen
February 25, 2021
457
Hi Jaime,

You didn't provide much details.

The 6 columns you mention are columns A to F in the code below. When the 6th column (F) is empty, then that row (columns A to E) are copied to column H at the first available row (occupying columns H to L).

Here is the code:
Sub RunMe()
For Each cell In Range("A2:A" & Range("A" & Rows.Count).End(xlUp).Row)
    If cell.Offset(0, 5).Value = vbNullString Then
        Range(Cells(cell.Row, "A"), Cells(cell.Row, "E")).Copy Range("H" & Rows.Count).End(xlUp).Offset(1, 0)
    End If
Next cell
End Sub


Let us know if further assistance is desired.

Best regards,
Trowa

Subscribe To Our Newsletter!

The Best of CCM in Your Inbox

Subscribe To Our Newsletter!