简体   繁体   English

删除工作表内容,但不删除宏按钮Excel Vba

[英]Delete sheet contents but not macro button Excel Vba

How can I delete the contents of a sheet including formatting without deleting a macro button? 如何删除工作表的内容(包括格式设置)而不删除宏按钮?

I am currently deleting the sheet contents 我目前正在删除工作表内容

sheets("Sheet").UsedRange.Delete

You can try something like this: 您可以尝试如下操作:

Option Explicit

Sub ClearCellsNotButton()

    With Sheets("Sheet1").UsedRange
        .ClearFormats
        .ClearContents
        .ClearComments
        .ClearHyperlinks
        .ClearOutline
        .ClearNotes
    End With

End Sub
Sheets("Sheet1").Cells.ClearContents

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM