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

Related Article

E-Commerce Solutions

Leverage the same tools powering the Alibaba Ecosystem

Learn more >

11.11 Big Sale for Cloud

Get Unbeatable Offers with up to 90% Off,Oct.24-Nov.13 (UTC+8)

Get It Now >

Alibaba Cloud Free Trial

Learn and experience the power of Alibaba Cloud with a free trial worth $300-1200 USD

Learn more >

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.