Clear Content Button

How To Add Clear Content Button in Excel?

Learn to add a Clear Content Button in Excel with the help of VBA code to Clear Contents of a specific range. Simplify your tedious jobs and save time.

Usually, we need to do many tasks repeatedly while creating spreadsheets in Excel. These include clearing cells, deleting ranges, printing ranges, etc. You can automate these tasks with the help of VBA in Excel.

Here, we will learn how to insert a command button to Clear Contents of a specific range in Excel.

Steps to Insert Clear Content Button in Excel Using VBA

5 Easy steps to insert Clear Content Button in Excel:

  1. Go to the Developer tab.
  2. Click on Insert in the Controls tab. Under ActiveX Controls, select Button. Draw the button at your desired location. Configure the button.
  3. Right-click on the button and select View Code. The Visual Basic window will open.
  4. Copy and Paste the code.
  5. Click on the Save icon and close the Visual Basic window.

Let’s understand it with the help of an example.

Example

Given below is an example of weekly attendance:

Weekly Attendance

In this data, the dates, days, and attendance section changes every week. Thus, to automate this process insert a formula for date and weekday. To clear the attendance section markings present/absent, we will insert and configure a Clear Content Button.

Go to Developer Tab and Click on Insert. Select the ActiveX control button. Draw the button beside the data and configure it.

ActiveX Control Button

To configure the button right-click the button and select Properties. You can rename the button by changing the caption. To change the fonts click on three dots at the end of the Fonts as shown in the figure below:

Clear Content Button

Now, Right-click on the button and select View Code. The Visual Basic window will open.

Clear Content Button

Copy and Paste the following between the code:

Range (“C5:H12”).ClearContents

VBA Module

Click on the Save icon and close the Visual Basic window.

Important Note: The C5: H12 is our range here. You can type in your desired range in the code.

Clear Content Button

That’s it. The Clear Content Button now clears the data from C5:H12 as shown in the image above.

Click the link below to download the sample file:

Sample File

Additionally, you can also download HR templates such as Salary Slip Excel Template India, Salary Slip Format UAESimple Salary Sheet, and Employee Salary Sheet from our website.

If you like this article, kindly share it on different social media platforms so that your friends and colleagues can also benefit from the same. Sharing is Caring.

If you have any queries or suggestions please share them in the comment section below. We will be more than happy to assist you.

%d bloggers like this: