Solved

Excel errors

Posted on 2014-09-10
4
279 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
Comment Utility
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
Comment Utility
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
Comment Utility
thank you.
0
 
LVL 27

Expert Comment

by:Glenn Ray
Comment Utility
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

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

Improved? Move/Copy Add-in Replacement - How to avoid the annoying, “A formula or sheet you want to move or copy contains the name XXX, which already exists on the destination worksheet.” David Miller (dlmille)  It was one of those days… I wa…
How to quickly and accurately populate Word documents with Excel data, charts and images (including Automated Bookmark generation) David Miller (dlmille) Synopsis In this article you’ll learn how to use ExcelToWord! to copy data,charts, shapes …
This Micro Tutorial will demonstrate on a Mac how to change the sort order for chart legend values and decrpyt the intimidating chart menu.
This Micro Tutorial demonstrates in Microsoft Excel how to consolidate your marketing data by creating an interactive charts using form controls. This creates cool drop-downs for viewers of your chart to choose from.

763 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

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now