Hi, I have written a macro code as below, however, there seems to be an error.
I am trying to select all rows in sheet 1 with an X in column E to have their respective columns F, G, H & I to be copied and pasted into sheet 2 starting with cell A1, but sheet 2 should not contain any blank rows.
Can anyone pls help to fine tune the macro?
Many thanks.
Sub Copy_Rows()
'Copy rows containing X
Sheets("Sheet1").Select
For Each r In Sheets("Sheet1").UsedRange.Rows
n = r.Row
If Sheets("Sheet1").Cells(n, 5) = "X" Then
Sheets("Sheet1").Range(Cells(n, 6), Cells(n, 9)).Copy
Sheets("Sheet2").Select
Range("A1").Select
Selection.PasteSpecial Paste:=xlPasteValuesAndNumberFormats, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Else
End If
Next r
End Sub
Bookmarks