Macro to copy values then delete row for entire sheet
Try this.
Sub Copy_Delete()
Dim LastRow As Long
Dim X As Long
LastRow = Cells(Rows.Count, 1).End(xlUp).Row
Application.ScreenUpdating = False
For X = LastRow To 2 Step -1
With Cells(X, 1)
If .Value = "myphrase" Then
.Offset(1, 0).Value = .Value
.EntireRow.Delete
End If
End With
Next X
Application.ScreenUpdating = True
End Sub
Gord
On Wed, 3 Dec 2008 10:08:02 -0800, Pyrotoy
wrote:
After copying the cell above, the macro will paste it into the current active
cell. (For example, if the target phrase appears in cell A4, the macro will
first copy the contents of A4 into A5, then delete row 4. Then it will repeat
this process for each occurrence of the target phrase.) Thanks for your help.
"Gord Dibben" wrote:
Copy the cell above and do what with it after copying?
Gord Dibben MS Excel MVP
On Tue, 2 Dec 2008 17:48:00 -0800, Pyrotoy
wrote:
I need a macro that, when it identifies a given target phrase, will copy the
cell above the target and then delete the entire row above the target. I
would like it to do this for mulitple occurrences of the target phrase on the
entire sheet. Please help. Thanks.
|