Hello Everyone
I have the below code where I am copying rows from the data tab that contain Day1 or Day2 or Day3 in column 9 and pasting these rows into the "Data2" tab. I then want to delete all the rows I have pasted to the new tab from the original data tab but am not sure how to do so. Some help would be greatly appreicated : ). Thanks.
Private Sub CommandButton1_Click()
a = Worksheets("Data").Cells(Rows.Count, 1).End(xlUp).Row
For i = 11 To a
If (Worksheets("Data").Cells(i, 9).Value = "Day 1" Or Worksheets("Data").Cells(i, 9).Value = "Day 2" Or Worksheets("Data").Cells(i, 9).Value = "Day 3" Then
Worksheets("Data").Rows(i).Copy
Worksheets("Data2").Activate
b = Worksheets("Data2").Cells(Rows.Count, 1).End(xlUp).Row
Worksheets("Data2").Cells(b + 1, 1).Select
ActiveSheet.Paste
Worksheets("Data").Activate
End If
Next
End Sub
I have the below code where I am copying rows from the data tab that contain Day1 or Day2 or Day3 in column 9 and pasting these rows into the "Data2" tab. I then want to delete all the rows I have pasted to the new tab from the original data tab but am not sure how to do so. Some help would be greatly appreicated : ). Thanks.
Private Sub CommandButton1_Click()
a = Worksheets("Data").Cells(Rows.Count, 1).End(xlUp).Row
For i = 11 To a
If (Worksheets("Data").Cells(i, 9).Value = "Day 1" Or Worksheets("Data").Cells(i, 9).Value = "Day 2" Or Worksheets("Data").Cells(i, 9).Value = "Day 3" Then
Worksheets("Data").Rows(i).Copy
Worksheets("Data2").Activate
b = Worksheets("Data2").Cells(Rows.Count, 1).End(xlUp).Row
Worksheets("Data2").Cells(b + 1, 1).Select
ActiveSheet.Paste
Worksheets("Data").Activate
End If
Next
End Sub