vba 我可以在不更改样式的情况下清除单元格内容吗?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/11137636/
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
Can I clear cell contents without changing styling?
提问by mezamorphic
Is there a way to clear the contents of multiple cells, but without changing the background/font properties of the cells?
有没有办法清除多个单元格的内容,但不更改单元格的背景/字体属性?
I am currently using Range("X").Cells.Clear
but its removing my background color and I would prefer not to have to "repaint" it on each clear.
我目前正在使用,Range("X").Cells.Clear
但它删除了我的背景颜色,我不想在每个清除上“重新绘制”它。
回答by stuartd
You should use the ClearContentsmethod if you want to clear the content but preserve the formatting.
如果要清除内容但保留格式,则应使用ClearContents方法。
Worksheets("Sheet1").Range("A1:G37").ClearContents