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:
- Open App Script.
- Copy and Paste the ClearCell Function Code into the App Script.
- Draw A button.
- Assign App Script to it.
Let us understand it in detail with an example.
Example
Given below is the Weekly Attendance data.
Go to Extension and select Apps Script.
The following window will open:
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.
The following window will appear.
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:
Select Assign Script from the menu and insert the name of the script as ClearCells.
Your Clear Content Button is ready to use. By pressing the button you get the following result:
Click the link below to download the 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.
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.