Clear Content Button Google Sheet

How To Insert Clear Content Button Google Sheet?

Learn to add a Clear Content Button Google Sheet with the help of App Script.  This will simplify tedious jobs and save time.

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

Here, we will learn how to insert a command button to clear the contents of a specific range in Google Sheet.

Steps to Insert Clear Content Button in Google Sheet Using App Script

4 easy steps to add a Clear Content Button in Google Sheet:

  1. Open App Script. 
  2. Copy and Paste the ClearCell Function Code into the App Script.
  3. Draw A button.
  4. Assign App Script to it.

Let us understand it in detail with an example.

Example

Given below is the Weekly Attendance data.

Clear Content Button Google Sheet

Go to Extension and select Apps Script.

Clear Content Button Google Sheet

The following window will open:

App Script

Select All and Delete. Copy and Paste the below code in the script:

function ClearCells() {
  var sheet = SpreadsheetApp.getActive().getSheetByName('Sheet1');
  sheet.getRange('B4:G11').clearContent();
   }

Insert the sheet name and range properly as per your requirement. Our sheet name is Sheet1 and Range is B4:G11.

Go to Insert Tab and Select Drawing.

Insert Button GS

The following window will appear.

Button Google Sheet

Draw the button selecting the Text Box function. Name it and format color, fonts, size, and background as per your requirement.

Set the button on the sheet at your desired location. Right-click the button and click on three dots to open the following dialog box:

App Script

Select Assign Script from the menu and insert the name of the script as ClearCells.

App Script

Your Clear Content Button is ready to use. By pressing the button you get the following result:

Clear Content Button Google Sheet

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.