PC Review


Reply
Thread Tools Rate Thread

cut paste row to end of WB based on criteria

 
 
aileen
Guest
Posts: n/a
 
      28th Oct 2008
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.

 
Reply With Quote
 
 
 
 
JLGWhiz
Guest
Posts: n/a
 
      28th Oct 2008
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.
>

 
Reply With Quote
 
aileen
Guest
Posts: n/a
 
      28th Oct 2008
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.
> >

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Copy and Paste based on criteria stacia Microsoft Excel Programming 1 12th Feb 2010 05:42 PM
Copy and Paste based on criteria stacia Microsoft Excel Misc 1 8th Feb 2010 09:04 PM
Copy/Paste data based on a criteria haas786@yahoo.com Microsoft Excel Programming 3 8th Feb 2008 10:35 PM
Copy/Paste based on Criteria Dan R. Microsoft Excel Programming 2 5th Feb 2007 08:25 PM
Help with copy/paste based on criteria Jayhawktc Microsoft Excel Programming 2 31st Mar 2004 04:05 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 02:14 AM.