Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 477
Default Why am I getting R/T 1004 - Copy method of Rng class failed?

Sub tester()
For Each cell In Sheets("Data").Range("A2:A10")
If cell.Value = "Stuff" Then
Cells(cell.Row, 7).Copy _
Destination:=Sheets("Sheet2").Cells(Rows.Count, 1).End(xlUp) + 1
End If
Next cell
End Sub
  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 35,218
Default Why am I getting R/T 1004 - Copy method of Rng class failed?

Sheets("Sheet2").Cells(Rows.Count, 1).End(xlUp) + 1

will try to add 1 to whatever is in that last used cell.

If you were using a LastRow kind of thing, you could use:
LastRow = Sheets("Sheet2").Cells(Rows.Count, 1).End(xlUp).row + 1

But I bet you just want to drop down a row.

Cells(cell.Row, 7).Copy _
Destination:=Sheets("Sheet2").Cells(Rows.Count, 1).End(xlUp).offset(1,0)

Jim May wrote:

Sub tester()
For Each cell In Sheets("Data").Range("A2:A10")
If cell.Value = "Stuff" Then
Cells(cell.Row, 7).Copy _
Destination:=Sheets("Sheet2").Cells(Rows.Count, 1).End(xlUp) + 1
End If
Next cell
End Sub


--

Dave Peterson
  #3   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 477
Default Why am I getting R/T 1004 - Copy method of Rng class failed?

Thanks Dave;
You assumed correctly.
Jim

"Dave Peterson" wrote:

Sheets("Sheet2").Cells(Rows.Count, 1).End(xlUp) + 1

will try to add 1 to whatever is in that last used cell.

If you were using a LastRow kind of thing, you could use:
LastRow = Sheets("Sheet2").Cells(Rows.Count, 1).End(xlUp).row + 1

But I bet you just want to drop down a row.

Cells(cell.Row, 7).Copy _
Destination:=Sheets("Sheet2").Cells(Rows.Count, 1).End(xlUp).offset(1,0)

Jim May wrote:

Sub tester()
For Each cell In Sheets("Data").Range("A2:A10")
If cell.Value = "Stuff" Then
Cells(cell.Row, 7).Copy _
Destination:=Sheets("Sheet2").Cells(Rows.Count, 1).End(xlUp) + 1
End If
Next cell
End Sub


--

Dave Peterson

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Error 1004 Copy method of worksheet class failed Ayo Excel Discussion (Misc queries) 3 March 28th 08 02:05 PM
Autofill method of range class failed Appache Excel Discussion (Misc queries) 5 February 27th 08 03:37 PM
Runtime 1004 error -- insert method of range class failed. tish Excel Discussion (Misc queries) 1 June 1st 07 04:04 PM
Run-Time error '1004' : Select method of Range class failed [email protected] Excel Discussion (Misc queries) 3 March 9th 07 01:36 PM
Run-time error "1004" Select method of range class failed Tallan Excel Discussion (Misc queries) 3 March 7th 07 05:22 PM


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

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"