资源描述:
《Excel出现“不同的单元格格式太多”解决方案.doc》由会员上传分享,免费在线阅读,更多相关内容在应用文档-天天文库。
1、Excel出现“不同的储存格式”解決方案原因:一个工作表常时间的使用,或经多人不同的编辑会使表格的格式日积月累越来越多,以至在2003以下的版的用户打不开(或格式超过4000种)大家可以去看看自己表格是否有过多的格式(色彩也是格式的一种)可以在单元格样式中看到。如何来清除过多的格式呢解決方案:打开出现“太多不同的储存格格式”的Excel文件;第一步:“开发工具”-“进入VB(VisualBasic)”(如下图)第二步:打开代码窗口,建模块,在代码窗口里將‘SubRebuildDefaultStyles’(见附档)档
2、案中的內容copy进去,替换原來的內容第三步:运行代码(点击运行里选择“运行子过程/用户窗体”或直接点击如图箭头所示)(如图)第四步:看看工作表的格式是不是已去除了,如下图那些在使用过程中留下的格式已除去了,只剩下Excel默认自带的格式。你的工作表如果格式太多了,最好清一清,工作时尽量不要更换太多不一样的格式。使用上述的办法不会对你的工作表内容更改。记得使用过后把代码删了。(文件占有空间也会变小)附档:SubRebuildDefaultStyles()'Thepurposeofthismacroistoremov
3、eallstylesintheactive'workbookandrebuildthedefaultstyles.'Itrebuildsthedefaultstylesbymergingthemfromanewworkbook.'Dimensionvariables.DimMyBookAsWorkbookDimtempBookAsWorkbookDimCurStyleAsStyle'SetMyBooktotheactiveworkbook.SetMyBook=ActiveWorkbookOnErrorResumeN
4、ext'Deleteallthestylesintheworkbook.ForEachCurStyleInMyBook.Styles'IfCurStyle.Name<>"Normal"ThenCurStyle.DeleteSelectCaseCurStyle.NameCase"20%-Accent1","20%-Accent2",_"20%-Accent3","20%-Accent4","20%-Accent5","20%-Accent6",_"40%-Accent1","40%-Accent2","40%-Acc
5、ent3","40%-Accent4",_"40%-Accent5","40%-Accent6","60%-Accent1","60%-Accent2",_"60%-Accent3","60%-Accent4","60%-Accent5","60%-Accent6",_"Accent1","Accent2","Accent3","Accent4","Accent5","Accent6",_"Bad","Calculation","CheckCell","Comma","Comma[0]","Currency",_"
6、Currency[0]","ExplanatoryText","Good","Heading1","Heading2",_"Heading3","Heading4","Input","LinkedCell","Neutral","Normal",_"Note","Output","Percent","Title","Total","WarningText"'Donothing,thesearethedefaultstylesCaseElseCurStyle.DeleteEndSelectNextCurStyle'O
7、penanewworkbook.SettempBook=Workbooks.Add'DisablealertssoyoumaymergechangestotheNormalstyle'fromthenewworkbook.Application.DisplayAlerts=False'Mergestylesfromthenewworkbookintotheexistingworkbook.MyBook.Styles.MergeWorkbook:=tempBook'Enablealerts.Application.D
8、isplayAlerts=True'Closethenewworkbook.tempBook.CloseEndSub