Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.misc
|
|||
|
|||
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
Posted to microsoft.public.excel.misc
|
|||
|
|||
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
Posted to microsoft.public.excel.misc
|
|||
|
|||
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 |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Error 1004 Copy method of worksheet class failed | Excel Discussion (Misc queries) | |||
Autofill method of range class failed | Excel Discussion (Misc queries) | |||
Runtime 1004 error -- insert method of range class failed. | Excel Discussion (Misc queries) | |||
Run-Time error '1004' : Select method of Range class failed | Excel Discussion (Misc queries) | |||
Run-time error "1004" Select method of range class failed | Excel Discussion (Misc queries) |