Combined use of Excel Range clear

Source: Internet
Author: User

① 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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.