RunTime 1004

dsainz

New Member
Joined
Sep 30, 2008
Messages
5
We are moving from Excel 2003 to 2007 and we have a report that reads from another spreadsheet. It still runs fine in 03 but in 07 we get the following error

Run-Time Error '1004' The information cannot be pasted because the Copy area and the paste are are not the same size and shape.

Enclosed is the code.

Dim AICount As Integer
Selection.AutoFilter
Selection.AutoFilter Field:=12, Criteria1:="AISCN"
Application.Columns("L:L").Select
Selection.Copy
Windows("AutoProdRpt.xls").Activate
Sheets("AISCN").Select
Application.Range("A1").Select
ActiveSheet.Paste
Application.Range("C2").Select
Application.CutCopyMode = False
Application.Range("C1").Value = "=COUNTA(A:A) - 1"
Windows(Right(strFileName, 12)).Activate
Selection.AutoFilter
Application.Range("A1").Select
Windows("AutoProdRpt.xls").Activate
End Sub

It has a yellow highlight over the ActiveSheet.Paste

Any assistance will be appreciated. Thank you.
 

Excel Facts

How can you turn a range sideways?
Copy the range. Select a blank cell. Right-click, Paste Special, then choose Transpose.
Welcome to the MrExcel board!

Are the Active Workbook and AutoProdRpt.xls both the same version of Excel? That is, do they both have 65,536 rows or both 1,048,576 rows? Untested, but instead of 'Selection.Copy', try:
Range("L1",Range("L" & Rows.Count).End(xlUp)).Copy
 
Upvote 0
I really don't think the reason it isn't working is a version issue.

You really need to lose all the Activate/Select/ActiveSheet etc.:eek:

I think I know what the purpose of the code but because of the above it's hard to tell exactly and/or post alternative code. :)
 
Upvote 0
Welcome to the MrExcel board!

Are the Active Workbook and AutoProdRpt.xls both the same version of Excel? That is, do they both have 65,536 rows or both 1,048,576 rows? Untested, but instead of 'Selection.Copy', try:
Range("L1",Range("L" & Rows.Count).End(xlUp)).Copy

Thank you for your help Peter. That did clear the error, but unfortunalty the data did not paste. I am by no means a VBA expert, I am just a helpdesk guy that got draft :(.
 
Upvote 0
I really don't think the reason it isn't working is a version issue.

You really need to lose all the Activate/Select/ActiveSheet etc.:eek:

I think I know what the purpose of the code but because of the above it's hard to tell exactly and/or post alternative code. :)


It is a script to copy and paste data out of an automated csv file into a production report excel document. As I mentioned in the above post I am just a help desk guy and not an expert in VB or excel. If you need anythign else from the code I will do my best to get that for you.
 
Upvote 0
Just an addon, it appears when I try and manually copy and paste just selected criteria, if I attempt to copy and paste the whole column there is no problem.
 
Upvote 0
I got it fixed:

I changed this line Application.Columns("L:L").Select to read

Application.Range("L1:L65536").Select

That has cleared up my problems. Thank you for all your help.
 
Upvote 0

Forum statistics

Threads
1,223,214
Messages
6,170,771
Members
452,353
Latest member
strainu

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