Solved

MS Excel VBA - Can not copy paste rows if columns total 298

Posted on 2014-10-31
4
88 Views
Last Modified: 2014-11-01
I run the below code fine 99.9% of the time, but today I hit a problem when the sheet I was trying to copy had 298 columns.  I got an error that the size/shape did not match between source and target.

How can I resoleve the issue.  If I do a manual cut and paste I do not get an error.


Sub dfsjijsdfkoiewa()

    Sheets("Sheet1").Cells.Copy

    Sheets("Sheet2").Cells.PasteSpecial Paste:=xlPasteValues............................................

    Application.CutCopyMode = False

End Sub
0
Comment
Question by:upobDaPlaya
  • 2
  • 2
4 Comments
 
LVL 27

Expert Comment

by:Glenn Ray
ID: 40416886
Where you do specify/select the range of cells to copy?

You could change the second command to show the anchor cell only, for example:
Sheets("Sheet2").Range("A1").PasteSpecial Paste:=xlPasteValues

-Glenn
0
 

Author Comment

by:upobDaPlaya
ID: 40417266
Tried that and i am getting an error..i will paste the error when i get home..
0
 
LVL 27

Accepted Solution

by:
Glenn Ray earned 500 total points
ID: 40417427
If you're using a version of Excel earlier than 2007 - or pasting into a 97-2003 file (.xls) you'll encounter this error because those versions were limited to 256 columns.
0
 

Author Closing Comment

by:upobDaPlaya
ID: 40417640
Glenn...that was it...once I changed the export code to xlsx (I have code in another module that creates the source workbook which was being done in xls)  and I did your code it woked beautiful.  Thanks !
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Convert between Excel file formats (.XLS, .XLSX, .XLSM) with/without macro option David Miller (dlmille) Intro Over this past Fall, I've had the opportunity to see several similar requests and have developed a couple related solutions associate…
Excel can be a tricky bit of software to get your head around. Whilst you’ll be able to eventually get to grips with the basic understanding of how to get by, there are a few Excel tips that not everybody will even know about let alone know how to d…
This Micro Tutorial will demonstrate on a Mac how to change the sort order for chart legend values and decrpyt the intimidating chart menu.
Many functions in Excel can make decisions. The most simple of these is the IF function: it returns a value depending on whether a condition you describe is true or false. Once you get the hang of using the IF function, you will find it easier to us…

713 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question