使用 VBA 从整个工作表中删除格式
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/20833378/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Removing Formats From Entire Worksheet with VBA
提问by Behseini
Using VBA, I am trying to Clear all Formats all entire of the active Worksheet.
使用 VBA,我试图清除所有活动工作表的所有格式。
Dim ws As Worksheet
Set ws = ThisWorkbook.ActiveSheet
With ws
.ClearFormats
End With
But I am getting following error:
但我收到以下错误:
However using the same code with .UsedRange works fine as:
但是,使用与 .UsedRange 相同的代码可以正常工作:
With .UsedRange
.ClearFormats
End With
Can you please let me know how fix this to format entire sheet!
您能否让我知道如何解决此问题以格式化整个工作表!
回答by chris neilsen
ClearFormats
is a method of a Range
, wereas ActiveSheet
is a Worksheet
ClearFormats
是 a 的方法Range
,areasActiveSheet
是 aWorksheet
You could use
你可以用
ThisWorkbook.ActiveSheet.Cells.ClearFormats
(Cells
is a range of all the cells on a worksheet)
(Cells
是工作表上所有单元格的范围)