Run Time Error '1004' PasteSpecial method of Range class failed.

TDPorter

New Member
Joined
Sep 13, 2011
Messages
12
So it worked perfectly!... Until I tried to use it for some additional cells that I wanted to copy from the temp file to the active worksheet "overview". What am I doing wrong? The error I recieved is as follows:

Run Time Error '1004' PasteSpecial method of Range class failed.

See code below:

Dim wbS As Workbook
Dim ws As Worksheet, wsA As Worksheet
Dim myFile As String
Set wsA = ThisWorkbook.Sheets("overview")
myFile = Application.GetOpenFilename("Excel Files (*.xls), *.xls")
Set wbS = Workbooks.Open(myFile, False, True)
Set ws = wbS.Sheets("DAILY TALLY")
ws.Range("D31:S31").Copy
wsA.Range("O40").PasteSpecial Paste:=xlPasteValues, Transpose:=True
ws.Range("U31:W31").Copy
wsA.Range("J48").PasteSpecial Paste:=x1PasteValues, Transpose:=True
 
So I addded it to the top of my module. Compiled the project then stepped through and it worked. I then closed VBA and ran the macro via the ActiveX button on my sheet and it executed without error. Did I need to compile? Maybe that was the issue? Hmmm.... In any case, thank you!!
 
Upvote 0

Excel Facts

Bring active cell back into view
Start at A1 and select to A9999 while writing a formula, you can't see A1 anymore. Press Ctrl+Backspace to bring active cell into view.
Using Option Explicit would prevent you compiling the code if there was a problem.:)
 
Upvote 0

Forum statistics

Threads
1,215,513
Messages
6,125,253
Members
449,219
Latest member
daynle

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