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

Solved/Closed
jaime.mmm - Updated on Feb 24, 2021 at 02:09 AM
TrowaD Posts 2921 Registration date Sunday September 12, 2010 Status Moderator Last seen December 27, 2022 - Feb 25, 2021 at 12:05 PM
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
Related:

1 response

TrowaD Posts 2921 Registration date Sunday September 12, 2010 Status Moderator Last seen December 27, 2022 552
Feb 25, 2021 at 12:05 PM
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

0