runtime error 1004

verlaine

New Member
Joined
Aug 16, 2002
Messages
43
Hi,
I have the following macro who now return a runtime error 1004, paste method of worksheet class failed.

I don't know how to change it to make it work. Any help ?

Sub Paste_TOP()

Sheets("Details TOP per month").Select
Cells.Select
Range("C1").Activate
Selection.EntireColumn.Hidden = False 'Unhide all columns

NextRow = Range("C65536").End(xlUp).Row + 1
Cells(NextRow, 1).Select 'select next free row

ActiveSheet.Paste
Application.CutCopyMode = False

End Sub
 

Excel Facts

What did Pito Salas invent?
Pito Salas, working for Lotus, popularized what would become to be pivot tables. It was released as Lotus Improv in 1989.
Have you copied something before you trigger the macro?

If you have then try something like:

Code:
Sub Paste_TOP()
With Sheets("Details TOP per month")
    .Cells.EntireColumn.Hidden = False 'Unhide all columns
    NextRow = .Range("C" & Rows.Count).End(xlUp).Row + 1
    .Cells(NextRow, 1).PasteSpecial
End With
Application.CutCopyMode = False
End Sub
 
Upvote 0
Have you copied something before you trigger the macro?

If you have then try something like:

Code:
Sub Paste_TOP()
With Sheets("Details TOP per month")
    .Cells.EntireColumn.Hidden = False 'Unhide all columns
    NextRow = .Range("C" & Rows.Count).End(xlUp).Row + 1
    .Cells(NextRow, 1).PasteSpecial
End With
Application.CutCopyMode = False
End Sub

Doesn't work i have the same runtime error..
 
Upvote 0
It worked for me on a test workbook. Can you code the copy into your module? Do you have to copy the cells manually?
 
Upvote 0
It worked for me on a test workbook. Can you code the copy into your module? Do you have to copy the cells manually?

Yes the macro is in a module. As the selection criteria change for the copy I do it manually.

When I run the macro from the VBA screen (Alt+F11) it works. When I run the macro using the menu Tools > Macros > Macros > Run I have the runtime error.

Any ideas what the difference ?
 
Upvote 0
try
Rich (BB code):
Sub Paste_TOP()
Dim rng As Range
Set rng = Application.InputBox("select range to copy", type:=8)
rng.Copy Workbooks("YourOtherWorkbook.xls").Sheets("Details TOP per month") _
    .Range("C65536").End(xlUp)(2)
Application.CutCopyMode = False
End Sub
Change YourOtherWorkbook to actual workbook name.<!-- / message --><!-- sig -->
 
Upvote 0

Forum statistics

Threads
1,215,062
Messages
6,122,923
Members
449,094
Latest member
teemeren

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top