Solved

Excel errors

Posted on 2014-09-10
4
292 Views
Last Modified: 2014-10-09
Have an Excel file we are working with.  It is about 10Mb, has probably 15-20 tabs in it, and many formulas throughout.  We are working with Office 2010 version of Excel.  When user tries to paste, she is getting an error of "Microsoft cannot paste the data".  She is copying from one Excel file to another Excel file.  Cells are identical layout.

When she tries to change the colors of three separate cells, all in the same row, and all right next to each other, she gets "Too Many Different Cell Formats".  

Any help on this at all?
0
Comment
Question by:akdreaming
  • 2
4 Comments
 
LVL 27

Accepted Solution

by:
Glenn Ray earned 500 total points
ID: 40315418
I deal with this on a regular basis.  The file is probably the result of several other Excel files having been cut and pasted into this one, with their source formatting/styles/range names all being globbed into this.  You finally get to a point where there can be thousands of useless styles and bad names in a document.  Eventually, one ends up with the kind of issues you're having right now.

To clean these files, I usually end up editing the underlying XML data (convert file to a zip file, then use an advanced text editor to remove the extraneous styles and range names).  However, here are a couple of macros that might work:
Sub DelStyle()
    ' macro from Dave Peterson, Excel MVP
    'On Error Resume Next
    Dim myStyle As Style
    For Each myStyle In ActiveWorkbook.Styles
        If myStyle.BuiltIn Then
            'do nothing
        Else
            myStyle.Delete
        End If
    Next myStyle
    MsgBox "Done!", vbOKOnly, "Deleted Styles"
End Sub

Open in new window


Sub Remove_Bad_Names()
    'Removes range names with invalid references (non-existent)
    Dim testRng As Range
    Dim myName As Name
    For Each myName In ActiveWorkbook.Names
        Set testRng = Nothing
        On Error Resume Next
        Set testRng = myName.RefersToRange
        On Error GoTo 0
        If testRng Is Nothing Then
            'doesn't refer to a real range
            'MsgBox myName.Name
            myName.Delete
        End If
    Next myName
End Sub

Open in new window


If the data isn't proprietary, you could attach it here and I'd be glad to clean up your file extensively.

Regards,
-Glenn
0
 
LVL 14

Expert Comment

by:ThomasMcA2
ID: 40316171
An error while copying or pasting could happen because of a filter. When a filter is enabled, Excel must "select" multiple chunks of data. For example, rows 2-5, 10-12, 20-30 all match the filter, so those data chunks must be selected. When you have thousands of rows, those chunks can create memory issues when copying and/or pasting.

If the user has filters enabled on the data being copied, remove the filter, then sort on the filtered column(s), then re-enable the filter, then try the copy and paste again.
0
 

Author Closing Comment

by:akdreaming
ID: 40371823
thank you.
0
 
LVL 27

Expert Comment

by:Glenn Ray
ID: 40371839
I'd forgotten about this thread.  

Since then I've started using the XLStylesTool and have to say I'm very impressed with how fast and thorough it runs.  Microsoft even mentions it in one of their KB articles (KB213904).

-Glenn
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Microsoft Office Picture Manager was included in Office 2003, 2007, and 2010, but not in Office 2013. Users had hopes that it would be in Office 2016/Office 365, but it is not. Fortunately, the same zero-cost technique that works to install it with …
This article descibes how to create a connection between Excel and SAP and how to move data from Excel to SAP or the other way around.
Graphs within dashboards are meant to be dynamic, representing data from a period of time that will change each time the dashboard is updated with new data. Rather than update each graph to point to a different set within a static set of data, t…
This Micro Tutorial will demonstrate on a Mac how to change the sort order for chart legend values and decrpyt the intimidating chart menu.

733 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