excel VBA批量删除自定义单元格样式
时间:2023-08-15 15:43:50
在Excel中可通过内置或自定义的单元格样式直接设置单元格格式,十分方便。而在Excel 2007/2010中,在“开始”选项卡的“样式”组中,单击“单元格样式”可在样式库中直接选择,显得更加方便。
有时会遇到这种情况,工作簿中的自定义单元格样式非常多,需要将其全部删除,如果手动逐一操作显得有些繁琐,如下图所示的自定义单元格样式。
这时用下面的VBA代码可一次删除所有的自定义单元格样式,方法如下。
1.按Alt+F11打开VBA编辑器,在代码窗口中输入下列代码:
Sub DelCustomStyles()
Dim st As Style
For Each st In ActiveWorkbook.Styles
If Not st.BuiltIn Then st.Delete
Next
End Sub
2.关闭VBA编辑器,返回Excel界面。按Alt+F8,打开“宏”对话框,执行“DelCustomStyles”宏即可一次删除所有自定义单元格样式,而内置的单元格样式会保留,如下图。
说明:删除全部自定义单元格样式后,对于应用过这些样式的单元格或区域,其单元格格式也会同时被清除
标签:删除,单元格,样式,自定义,Excel函数
![](/images/zang.png)
![](/images/jiucuo.png)
猜你喜欢
word中如何设置公文每页22行每行28个字符的方法
2023-04-10 05:54:29
![](https://img.aspxhome.com/file/2023/8/32338_0s.png)
Win10系统与geforce game ready driver441.66不兼容安装不了怎么办?
2022-03-15 01:51:01
![](https://img.aspxhome.com/file/2023/26/a221326_0s.jpg)
Win7系统黑屏提示TsFltmgr.sys文件出错不能正常开机怎么修复
2022-01-19 06:04:57
![](https://img.aspxhome.com/file/2023/3/a292833_0s.jpg)
win7电脑提示此程序被组策略阻止如何解决?
2022-10-04 00:04:10
![](https://img.aspxhome.com/file/2023/2/a291346_0s.jpg)
Apple ID 付款方式为什么不能选择“无”,如何解决?
2023-08-10 08:20:51
![](https://img.aspxhome.com/file/2023/6/a198126_0s.jpg)
word怎么设置页眉页脚页码不同
2022-07-07 08:38:45
0xc0000102错误代码是什么意思?0xc0000102错误代码解决办法
2023-05-29 14:54:44
![](https://img.aspxhome.com/file/2023/6/a321932_0s.jpg)
Excel如何将表格改成虚线
2023-04-05 16:37:18
![](https://img.aspxhome.com/file/2023/1/37841_0s.jpg)
Win10怎么永久删除文件 Win10永久删除快捷键是什么
2022-08-24 16:52:20
![](https://img.aspxhome.com/file/2023/29/a260962_0s.jpg)
wps如何制作工作牌
2022-02-07 18:48:42
万兴神剪手如何对视频中的某一片段进行加速?
2022-06-09 18:44:56
DNF怎么解除安全模式?
2022-11-07 08:57:53
![](https://img.aspxhome.com/file/2023/2/a290768_0s.png)
excel表格中录入公式的方法
2023-06-14 17:31:51
修复损坏的WORD文档的11个技巧
2022-10-13 17:40:49
iOS 13 如何更新应用,如何突破 200 MB 下载限制?
2022-03-06 07:15:16
![](https://img.aspxhome.com/file/2023/9/a196519_0s.jpg)
word排版好的文件怎么直接转换成印刷稿文件?
2022-12-12 07:24:47
![](https://img.aspxhome.com/file/2023/1/28971_0s.jpg)
Win10无法更新错误代码0x80070424怎么解决?
2023-12-13 11:37:51
![](https://img.aspxhome.com/file/2023/3/51953_0s.jpg)
电脑桌面右下角总是弹出QQ广告窗口的拦截方法
2022-09-14 14:30:23
![](https://img.aspxhome.com/file/2023/3/a296213_0s.jpg)
Win7系统当中IDE通道的自动检测时间太长如何解决?
2022-03-19 14:38:30
![](https://img.aspxhome.com/file/2023/2/a285697_0s.jpg)
三种创建excel数据透视表的方法
2022-10-06 13:50:27
![](https://img.aspxhome.com/file/2023/1/37181_0s.jpg)