jlrich12002
New Member
- Joined
- Jun 9, 2018
- Messages
- 4
I want to copy and paste a row to a new sheet when a cell in that row contains a certain text string (not the whole cell value as shown in code below). How do I modify this code so that it finds any row that contains the string? Also, if you could edit this so that it never appends the rows to the bottom of the new sheet – I always want it to rewrite over the entire sheet if the macro is run.
Thank you so much for any help that you can provide.
Private Sub CommandButton1_Click()
a = Worksheets("PnP Inventory List").Cells(Rows.Count, 1).End(xlUp).Row
For i = 2 To a
If Worksheets("PnP Inventory List").Cells(i, 5).value = ("insert text string here") Then
Worksheets("PnP Inventory List").Rows(i).Copy
Worksheets("ECCJROnly").Activate
b = Worksheets("ECCJROnly").Cells(Rows.Count, 1).End(xlUp).Row
Worksheets("ECCJROnly").Cells(b + 1, 1).Select
ActiveSheet.Paste
End If
Next
Application.CutCopyMode = False
ThisWorkbook.Worksheets("PnP Inventory List").Cells(1, 1).Select
End Sub
Thank you so much for any help that you can provide.
Private Sub CommandButton1_Click()
a = Worksheets("PnP Inventory List").Cells(Rows.Count, 1).End(xlUp).Row
For i = 2 To a
If Worksheets("PnP Inventory List").Cells(i, 5).value = ("insert text string here") Then
Worksheets("PnP Inventory List").Rows(i).Copy
Worksheets("ECCJROnly").Activate
b = Worksheets("ECCJROnly").Cells(Rows.Count, 1).End(xlUp).Row
Worksheets("ECCJROnly").Cells(b + 1, 1).Select
ActiveSheet.Paste
End If
Next
Application.CutCopyMode = False
ThisWorkbook.Worksheets("PnP Inventory List").Cells(1, 1).Select
End Sub