Excel Hw to delete a row from an excel sheet after copying its contents to another sheet

Joined
Oct 25, 2012
Messages
2
Reaction score
0
Hi,
I have written the below code to check the column in sheet "A" and if it matches any of the conditions, I copy it to sheet "B". But I also want to delete the whole row (not just clear its contents) from sheet "A" after copying it to sheet "B". I tried a lot of codes for that, but none worked! :(
Please help..

Sub a()

Sheets("A").Range("A1:J3").Copy Sheets("B").Range("A1")


Dim i As Long, iMatches1 As Long, iMatches2 As Long
iMatches1 = 3
For Each cell In Sheets("A").Range("F:F")
If (cell.Value = "x") Or (cell.Value = "y") Or (cell.Value = "z") Or (cell.Value = "u") Or (cell.Value = "v") Or (cell.Value = "w") Then
iMatches1 = (iMatches1 + 1)
Sheets("A").Rows(cell.Row).Copy Sheets("B").Rows(iMatches1)

End If
Next
 
hi
after
Sheets("A").Rows(cell.Row).Copy Sheets("B").Rows(iMatches1)
you type
Sheets("A").Rows(cell.Row).Delete

i hope that i've answered you
 
Back
Top