Run-time error -1004 (Paste method of Worksheet class failed)

Chandresh

Board Regular
Joined
Jul 21, 2009
Messages
146
I am getting Run-time error -1004 (Paste method of Worksheet class failed).

Steps - I am copying data from one macro file to another file, Could you please resolve the issue.


Sub ABCD()
Dim Wb As Workbook
Dim bk As Workbook
Dim strFName As String
Dim ws As Worksheet
Dim sh As Worksheet
Dim shRng As Range
Set Wb = ThisWorkbook
Set ws = Wb.Sheets("Process")
strFName = ws.Range("B10").Value
Workbooks.Open Filename:=strFName
Application.Wait (Now + TimeValue("0:00:10"))

'>>>>For copying name
Workbooks("ABC6M.xlsm").Worksheets("Data").Range("B2").Copy
Windows("ITR6_V1.4.xlsm").Activate
Sheets("PART ").Select
Range("E10:E10").Select
ActiveSheet.Paste
 

Excel Facts

Workdays for a market open Mon, Wed, Friday?
Yes! Use "0101011" for the weekend argument in NETWORKDAYS.INTL or WORKDAY.INTL. The 7 digits start on Monday. 1 means it is a weekend.
Which line of code does it highlight if you click "Debug"?

Did you confirm that all your file names and sheet names match exactly?

Do you really have a space in the PART sheet name at the end?
VBA Code:
Sheets("PART ").Select
 
Upvote 0
Is range B2 that you are copying from on the Data sheet protected, or part of a merged range?
Is range E10 on the Part sheet protected, or part of a merged range?
 
Upvote 0
Is range B2 that you are copying from on the Data sheet protected, or part of a merged range? - NO
Is range E10 on the Part sheet protected, or part of a merged range? - YES(sheet is protected but cell is not protected we can edit) & Cell is part of merged cell.
 
Upvote 0
Is range E10 on the Part sheet protected, or part of a merged range? - YES(sheet is protected but cell is not protected we can edit) & Cell is part of merged cell.
What cell(s) is E10 merged with?

Merged cells are just about the worst thing in Excel, and cause all sorts of issues for things (like VBA).
It is HIGHLY recommended that you not use them (most serious programmers won't/don't use them).

If you are just trying to merge cells across single rows, then the "Center Across Selection" formatting option is a much better choice (it gives you the same visual effect without all the issues).
See: Tom’s Tutorials For Excel: Using Center Across Selection Instead of Merging Cells – Tom Urtis

See if it works when you removed the merged cell.
 
Upvote 0

Forum statistics

Threads
1,214,585
Messages
6,120,388
Members
448,957
Latest member
Hat4Life

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