cut paste row to end of WB based on criteria

A

aileen

I am trying to cut a row of data that has either a blank cell in column G or
column H and paste the whole row to the first blank row at the end of the
active worksheet. the code I am trying is as follows:

With ActiveSheet
lr = ActiveSheet.Cells(Rows.Count, 1).End(xlUp).Row
For i = lr To 1 Step -1
If Trim(.Cells(i, 8).Value) = "" _
Or Trim(.Cells(i, 7).Value) = "" Then
.Cells(i, 1).EntireRow.Cut
Range("A65536").End(xlUp).Select
r = Selection.Row + 1
Range("A" & r).Select.EntireRow.Paste
End If
Next i
End With

I am getting an object required error. Any help is always appreciated. Thanks.
 
J

JLGWhiz

See if this will work

With ActiveSheet
lr = ActiveSheet.Cells(Rows.Count, 1).End(xlUp).Row
For i = lr To 1 Step -1
If Trim(.Cells(i, 8).Value) = "" _
Or Trim(.Cells(i, 7).Value) = "" Then
.Cells(i, 1).EntireRow.Cut
.Range("A65536").End(xlUp).Select
r = Selection.Row + 1
.Range("A" & r).Insert
End If
Next i
End With
 
A

aileen

Worked perfectly. Thank you!

JLGWhiz said:
See if this will work

With ActiveSheet
lr = ActiveSheet.Cells(Rows.Count, 1).End(xlUp).Row
For i = lr To 1 Step -1
If Trim(.Cells(i, 8).Value) = "" _
Or Trim(.Cells(i, 7).Value) = "" Then
.Cells(i, 1).EntireRow.Cut
.Range("A65536").End(xlUp).Select
r = Selection.Row + 1
.Range("A" & r).Insert
End If
Next i
End With
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top