Hi xld I actually just came up with a temporary solution, (trying to think outside the box!) while it won't insert the line above it will below if I add in a sort code under my code such as:
Range("A1:W5000").Sort _
Key1:=Range("A1"), Order1:=xlDescending
It eliminates the need to insert as sorting naturally arranges the product codes which is I am looking to arrange next to each other.
The code I was working with is:
Public Sub CopyRows()
'Sheets("WAProducts").Select
Sheets("WAProducts").Select
' Find the last row of data
Finalrow = Cells(Rows.Count, 1).End(xlUp).Row
' Loop through each row
For x = Finalrow To 2 Step -1
' Decide if to copy based on column R
ThisValue = Cells(x, 18).Value
If ThisValue > 1 Then
Cells(x, 1).Resize(1, 22).Copy
Rows(x).Insert shift:=xlShiftDown
Cells(x, 1).Select
ActiveSheet.Paste
Cells(x, 18) = " "
Cells(x, 18) = 1
End If
Next x
End Sub
while it worked perfectly for small amounts of data it would crash when trying with 3000 rows.
As such the new code just inserts the new lines at the next available row I believe being faster and then sorts the data:
Public Sub CopyRows()
Sheets("WAProducts").Select
' Find the last row of data
FinalRow = Cells(Rows.Count, 1).End(xlUp).Row
' Loop through each row
For x = 2 To FinalRow
' Decide if to copy based on column R
ThisValue = Cells(x, 18).Value
If ThisValue > 1 Then
Cells(x, 1).Resize(1, 22).Copy
Sheets("WAProducts").Select
NextRow = Cells(Rows.Count, 1).End(xlUp).Row + 1
Cells(NextRow, 1).Select
ActiveSheet.Paste
Sheets("WAProducts").Select
Cells(NextRow, 18) = " "
Cells(NextRow, 18) = 1
End If
Next x
Range("A1:W5000").Sort _
Key1:=Range("A1"), Order1:=xlDescending
End Sub
If you want to have fun with it looking for a different way (and one that inserts it above [and still changes the value of the copied row in column R to 1]) then that would be fab! But if other people need help I have a tiny work around Thankyou so much for your response