① clears the contents of a cell
Use (ClearContents method)
Sub testclearcontents ()
MsgBox "Clears the contents of a specified range of cells"
Worksheets (9). Range ("B1:f8"). ClearContents
End Sub
As with the code function, the B1:f8 of this range of data for the 9th worksheet is cleared.
② clear the formatting in a cell
Use (ClearFormats method)
Sub Testclearformats ()
MsgBox "Clear formatting in specified range of cells"
Worksheets (9). Range ("B1:f8"). ClearFormats
End Sub
As with the code function, the B1:f8 of this range of cells on the 9th worksheet is cleared.
③ clear a comment in a cell
Use (Clearcomments method)
Sub testclearcomments ()
MsgBox "clear annotations in specified range of cells"
Worksheets (9). Range ("B1:f8"). Clearcomments
End Sub
As with the code function, the B1:f8 of this range of cells on the 9th worksheet is cleared.
④ clears all cells, including content, formatting, and annotations
Use (Clear method)
Sub Testclear ()
MsgBox "Clear the specified range of cells"
Worksheets (9). Range ("B1:f8"). Clear
End Sub