ExcelTip.Net留存知识帖 ---【注:附件之前被网盘供应商清空后,现已修复-现已修复-现已修复为本地下载!】
现在位置:首页 > E文精选 > 操作与技巧 > 终极解决EXCEL“不同单元格格式太多”的问题

终极解决EXCEL“不同单元格格式太多”的问题

作者:绿色风 分类: 时间:2022-08-17 浏览:374
楼主
yd0209
基本审计程序.rar
在英文版中的提示是 Too many different cell formats.
一旦出现这个问题,文件可能无法打开。
微软的这个错误可以出现在EXCEL 2003 及以前的各个版本,却没法提出解决方案,实在愚蠢。
微软只是在网站上说,系统给的限制应该足够了。废话,足够了还能有这个错误信息吗?
很多表格合并后一直到“保存成功”都看不到任何警告,等打开就不行了,灾难啊。

搜索中文网站一无所获,无非让你手工修改格式。
搜索2个多小时的英文网站,找到很多比较容易的解决方案。

解决方案一:
http://xlsgenreduction.arstdesign.com
对处理过的文件再反复处理(如果是注册版应该一次解决).我发现试用版还悄悄把几处内容改为他们的广告.
免费解决方案二:
下载一个OPEN OFFICE,打开后再保存成Excel格式,很多老外都这么说,我没有实践过。 OpenOffice.Org 免费下载。
方案三:
一个文件用EXCEL 07打开正常,存成2000格式后就打不开。那就用07打开,分成两(或三、四)部分存成2000格式。
方案四:
如果EXCEL文件能打开编辑,可以试验一下这个VB程序,从老外的网站上抄来的。(用EXCEL的运行宏功能)

  1. Sub DeleteUnusedCustomNumberFormats()
  2. Dim Buffer As Object
  3. Dim Sh As Object
  4. Dim SaveFormat As Variant
  5. Dim fFormat As Variant
  6. Dim nFormat() As Variant
  7. Dim xFormat As Long
  8. Dim Counter As Long
  9. Dim Counter1 As Long
  10. Dim Counter2 As Long
  11. Dim StartRow As Long
  12. Dim EndRow As Long
  13. Dim Dummy As Variant
  14. Dim pPresent As Boolean
  15. Dim NumberOfFormats As Long
  16. Dim Answer
  17. Dim c As Object
  18. Dim DataStart As Long
  19. Dim DataEnd As Long
  20. Dim AnswerText As String

  21. NumberOfFormats = 1000
  22. ReDim nFormat(0 To NumberOfFormats)
  23. AnswerText = "Do you want to delete unused custom formats from the workbook?"
  24. AnswerText = AnswerText & Chr(10) & "To get a list of used and unused formats only, choose No."
  25. Answer = MsgBox(AnswerText, 259)
  26. If Answer = vbCancel Then GoTo Finito

  27. On Error GoTo Finito
  28. Worksheets.Add.Move after:=Worksheets(Worksheets.Count)
  29. Worksheets(Worksheets.Count).Name = "CustomFormats"
  30. Worksheets("CustomFormats").Activate
  31. Set Buffer = Range("A2")
  32. Buffer.Select
  33. nFormat(0) = Buffer.NumberFormatLocal
  34. Counter = 1
  35. Do
  36. SaveFormat = Buffer.NumberFormatLocal
  37. Dummy = Buffer.NumberFormatLocal
  38. DoEvents
  39. SendKeys "{tab 3}{down}{enter}"
  40. Application.Dialogs(xlDialogFormatNumber).Show Dummy
  41. nFormat(Counter) = Buffer.NumberFormatLocal
  42. Counter = Counter + 1
  43. Loop Until nFormat(Counter - 1) = SaveFormat

  44. ReDim Preserve nFormat(0 To Counter - 2)

  45. Range("A1").Value = "Custom formats"
  46. Range("B1").Value = "Formats used in workbook"
  47. Range("C1").Value = "Formats not used"
  48. Range("A1:C1").Font.Bold = True

  49. StartRow = 3
  50. EndRow = 16384

  51. For Counter = 0 To UBound(nFormat)
  52. Cells(StartRow, 1).Offset(Counter, 0).NumberFormatLocal = nFormat(Counter)
  53. Cells(StartRow, 1).Offset(Counter, 0).Value = nFormat(Counter)
  54. Next Counter

  55. Counter = 0
  56. For Each Sh In ActiveWorkbook.Worksheets
  57. If Sh.Name = "CustomFormats" Then Exit For
  58. For Each c In Sh.UsedRange.Cells
  59. fFormat = c.NumberFormatLocal
  60. If Application.WorksheetFunction.CountIf(Range(Cells(StartRow, 2), Cells(EndRow, 2)), fFormat) = 0 Then
  61. Cells(StartRow, 2).Offset(Counter, 0).NumberFormatLocal = fFormat
  62. Cells(StartRow, 2).Offset(Counter, 0).Value = fFormat
  63. Counter = Counter + 1
  64. End If
  65. Next c
  66. Next Sh

  67. xFormat = Range(Cells(StartRow, 2), Cells(EndRow, 2)).Find("").Row - 2
  68. Counter2 = 0
  69. For Counter = 0 To UBound(nFormat)
  70. pPresent = False
  71. For Counter1 = 1 To xFormat
  72. If nFormat(Counter) = Cells(StartRow, 2).Offset(Counter1, 0).NumberFormatLocal Then
  73. pPresent = True
  74. End If
  75. Next Counter1
  76. If pPresent = False Then
  77. Cells(StartRow, 3).Offset(Counter2, 0).NumberFormatLocal = nFormat(Counter)
  78. Cells(StartRow, 3).Offset(Counter2, 0).Value = nFormat(Counter)
  79. Counter2 = Counter2 + 1
  80. End If
  81. Next Counter
  82. With ActiveSheet.Columns("A:C")
  83. .AutoFit
  84. .HorizontalAlignment = xlLeft
  85. End With
  86. If Answer = vbYes Then
  87. DataStart = Range(Cells(1, 3), Cells(EndRow, 3)).Find("").Row + 1
  88. DataEnd = Cells(DataStart, 3).Resize(EndRow, 1).Find("").Row - 1
  89. On Error Resume Next
  90. For Each c In Range(Cells(DataStart, 3), Cells(DataEnd, 3)).Cells
  91. ActiveWorkbook.DeleteNumberFormat (c.NumberFormat)
  92. Next c
  93. End If
  94. Finito:
  95. Set c = Nothing
  96. Set Sh = Nothing
  97. Set Buffer = Nothing
  98. End Sub
我上传一个附件,这个工作簿如果再往里面添加内容,就会引起格式丢失的问题,麻烦版主把这个106行的VBA程序放进去,我看看好使不好使。
演示.rar
2楼
syz105729913
谢谢楼主分享
3楼
yd0209
试验了VBA的方法,不好使!
4楼
niani
俺们深受其害,郁闷呀
5楼
ac98
下载openoffice试试看?这个我也有试过的,我的是一个文档打开的时候就提示“不同的单元格格式太多”,然后就是“.....中发现不可读取的内容,是否要恢复此工作簿的内容....”,然后又提示说“该文件的破坏程度较大不能恢复”。文件是能打开了,但是里面的好多格式啊,或者标题头都不见了。

下载OpenOffice.org 3.2后,用这个OpenOffice.org 3.2打开那个文档,能打开,然后就清除了全部标签页的格式,再保存,文件就正常了。唯一就是格式没了,不过这个可以过后手工设回来。
6楼
lrlxxqxa
学习一下:)
7楼
lpzxhjp
好帖子,大家分享!
8楼
健康快乐123
太深了看不懂

免责声明

有感于原ExcelTip.Net留存知识的价值及部分知识具有的时间限定性因素, 经与ExcelTip.Net站长Apolloh商议并征得其同意, 现将原属ExcelTip.Net的知识帖采集资料于本站点进行展示, 供有需要的人士查询使用,也慰缅曾经的论坛时代。 所示各个帖子的原作者如对版权有异议, 可与本人沟通提出,或于本站点留言,我们会尽快处理。 在此,感谢ExcelTip.Net站长Apolloh的支持,感谢本站点所有人**绿色风(QQ:79664738)**的支持与奉献,特此鸣谢!
------本人网名**KevinChengCW(QQ:1210618015)**原ExcelTip.Net总版主之一

评论列表
sitemap