Help with "PasteSpecial method of range class failed"

Overkill32

New Member
Joined
May 13, 2011
Messages
49
I'm trying to copy values from a workbook to another to create a list. Unfortunitly the run time error identified in the title keeps poping up when the code is asked to paste the range I defined in the other workbook. Here is the code I'm having trouble with. The underlined line is the one where the error keeps coming up.

With Application.FileSearch
.NewSearch
.LookIn = Dirr
.SearchSubFolders = True
.Filename = "file.xls"
.Execute
e = .FoundFiles.Count
End With

If e = 0 Then GoTo Noadds

If e <> 0 Then
Workbooks.Open Filename:=Dirr & "\file.xls", UpdateLinks:=True, ReadOnly:=True
Worksheets("Adds").Select
Range("C1000").End(xlUp).Select
If ActiveCell.Row = 3 Then
Windows("file.xls").Close
GoTo Noadds
End If
NumAdds = ActiveCell.Row
Range("C4:Y" & NumAdds).Copy
Range("C4:Y" & NumAdds).ClearContents
Windows("Masterfile_Adds.xls").Activate
Worksheets("List").Select
Range("C1000").End(xlUp).Select
Oldadds = ActiveCell.Offset(1, 0).Row
ActiveCell.Offset(1, 0).PasteSpecial Paste:=-4163
Range("C1000").End(xlUp).Select
newadds = ActiveCell.Row
For j = Oldadds To newadds
Range("Z" & j).Value = Analyst_Array(i)
Next j
Windows("file.xls").Close


Thanks who whoever can help me!
 

Excel Facts

Why are there 1,048,576 rows in Excel?
The Excel team increased the size of the grid in 2007. There are 2^20 rows and 2^14 columns for a total of 17 billion cells.
Does it work if you comment out?

Code:
Range("C4:Y" & NumAdds).ClearContents
 
Upvote 0

Forum statistics

Threads
1,224,524
Messages
6,179,304
Members
452,904
Latest member
CodeMasterX

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