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.

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

Key Takeaways

  • Google Sheets “Clear Content Button” can be created using Apps Script to automate repetitive data-clearing tasks. The process involves writing a simple script that targets a specific sheet and cell range for clearing content.
  • This automation helps save time in tasks like attendance sheets, reports, and frequently updated spreadsheets.
  • The setup is fully customizable, allowing users to define their own sheet name and range for clearing data.

Steps to Insert a Clear Content Button in Google Sheets Using Apps Script

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

  1. Open App Script. 
  2. Copy and Paste the ClearCell Function Code into the App Script.
  3. Draw A button.
  4. Assign the 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 Extensions and select Apps Script.

Clear Content Button Google Sheet

The following window will open:

App Script

Select All and Delete. Copy and paste the code below into 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 the range is B4:G11.

Go to the Insert Tab and Select Drawing.

Insert Button GS

The following window will appear.

Button Google Sheet

Draw the button by selecting the Text Box function. Name it and format the 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 the three dots to open the following dialog box:

App Script

Select Assign Script from the menu and enter 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 UAE,  Simple Salary Sheet, and Employee Salary Sheet from our website.

Frequently Asked Questions

What is the purpose of a Clear Content Button in Google Sheets?

It helps quickly erase data from selected cells without manually deleting them, saving time and effort.

Do I need coding knowledge to use Apps Script for this?

No, only basic copy-paste of the script is required along with minor edits like sheet name and range.

Can I clear multiple ranges using one button?

Yes, you can modify the script to include multiple ranges in a single function.

Will the button delete formulas or just values?

The clearContent() function only removes values, not formatting or sheet structure.

Can this button be used in shared Google Sheets?

Yes, but users must have editing access for the script and button to function properly.

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.

Click to listen highlighted text!