ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   cut paste row to end of WB based on criteria (https://www.excelbanter.com/excel-programming/419157-cut-paste-row-end-wb-based-criteria.html)

aileen

cut paste row to end of WB based on criteria
 
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.


JLGWhiz

cut paste row to end of WB based on criteria
 
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

"aileen" wrote:

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.


aileen

cut paste row to end of WB based on criteria
 
Worked perfectly. Thank you!

"JLGWhiz" wrote:

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

"aileen" wrote:

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.



All times are GMT +1. The time now is 10:49 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com