Copying a row based on part of a field
Solved/Closed
Erenagh
-
Aug 18, 2011 at 07:07 AM
TrowaD
TrowaD
- Posts
- 2888
- Registration date
- Sunday September 12, 2010
- Status
- Moderator
- Last seen
- August 16, 2022
Related:
- Copying a row based on part of a field
- Copying cond. format for entire row based on 1 cell to other row ✓ - Forum - Excel
- Excel duplicate rows based on cell value ✓ - Forum - Excel
- Excel create rows based on cell value - Forum - Excel
- Excel repeat rows based on cell value - Guide
- Excel copy row based on cell value ✓ - Forum - Excel
1 reply
TrowaD
Aug 18, 2011 at 10:43 AM
- Posts
- 2888
- Registration date
- Sunday September 12, 2010
- Status
- Moderator
- Last seen
- August 16, 2022
Aug 18, 2011 at 10:43 AM
Hi Erenagh,
You didn't specify the destination for the copied rows. In the below code I copied them to sheet2 in the first available cell of column A.
Here is the code:
Best regards,
Trowa
You didn't specify the destination for the copied rows. In the below code I copied them to sheet2 in the first available cell of column A.
Here is the code:
Sub Test() Dim lRow As Integer lRow = Sheets("Sheet1").Range("E" & Rows.Count).End(xlUp).Row Set MR = Sheets("Sheet1").Range("E1:E" & lRow) For Each Cell In MR If (InStr(1, Cell.Value, "X") > 0) Or (InStr(1, Cell.Value, "1Y") > 0) Then Cell.EntireRow.Copy Sheets("Sheet2").Range("A" & Rows.Count).End(xlUp).Offset(1, 0).PasteSpecial End If Next Application.CutCopyMode = False End Sub
Best regards,
Trowa