In this article, we’ll see the google sheets radio button, or google sheets checkboxes. In google sheets checkbox and radio buttons are identical, let’s see what they are? How do they work? And how can we use them?
In google sheets, we have formulas for using different features and functionalities, but here is something new called “Apps script” which is a script-based code that helps us to write complex problems to use google sheets functionalities more accurately. All the scripts will be provided here and you can use them according to your requirements. So, let’s get started.
Why do we need to use Google sheets Radio button?
Radio buttons and checkboxes are two identical terms that are most commonly used in web, app, and other forms to receive the user input as an option from the given options. Checkboxes or radio buttons allow us to create a poll and attach different checkboxes there, so the user can use one or more than one option as an answer. It is pretty like multiple-choice questions. We need this when we want to know people’s opinions about a product. Yes! we need this feature to ask our users their gender, their favorite color, and many similar things. So, this is where we need to use the google sheets radio button in our content. This feature is most commonly seen in a contact form on the web.
Code to Make Functional Radio Buttons in Google Sheets
/** * onEdit to uncheck checkboxes as required */ function onEdit(e) { // get event object data: sheet name, row number and column number const sheet = e.range.getSheet(); const row = e.range.rowStart; const col = e.range.columnStart; switch(col) { // case when column B is checked case 2: sheet.getRange("C" + row + ":E" + row).uncheck(); break; // case when column C is checked case 3: sheet.getRangeList(["B" + row,"D" + row + ":E" + row]).uncheck(); break; // case when column D is checked case 4: sheet.getRangeList(["B" + row + ":C" + row,"E" + row]).uncheck(); break; // case when column E is checked case 5: sheet.getRange("B" + row + ":D" + row).uncheck(); break; // cell is outside of columns B to D default: return; } }
Source: https://www.benlcollins.com/apps-script/radio-buttons-in-google-sheets/
Video Tutorial: How to Insert Radio Button in Google Slides
How to Insert Radio Button in Google Sheets
Step 1
Copy the data checkbox template from the below link. Go to the link, then in the google sheet go to file > make a copy.
Link: shorturl.at/bhpzR
Step 2
Go to tools > script editor.
Or
Go to extension > Apps Script
Step 3
In the script editor below, copy and paste the script provided below in this article
Step 4
Now run the code to authorize the script
Step 5
Go back to the google sheets to see the google sheets radio buttons are added and working properly
Step 6
Go to the script editor/apps script and understand the code to customize your checkbox/radio button, click on insert > tick box to add a single radio button.
Notes
- If you are new to the google sheets radio button, then it is recommended to copy and paste the sheet data and script to go with your first checkbox.
- If you are habitual of using this feature then you can create your own from scratch, remember it can be tricky at the first time because it involves a script and formulas to make the radio buttons functions properly and cleanly.
- Always remember the function of selecting multiple checkboxes when you are creating one, this feature is only for the cases where you want to receive multiple answers for a specific question, in other cases you may need the only answer of a question for example a multiple-choice question in an online exam.
Conclusion
Today we learned the google sheets radio buttons, by definition they are pretty simple and straightforward, but for execution, they can be a little tricky for newbies. The best practice for newbies is to copy the code and the sheet provided in the article and then go through the code to understand it and then play around to make changes, this practice will help you understand the different aspects of the script to customize the radio button, and you will learn to edit code and then you can create your customized radio button from scratch. If you like this quick guide please don’t forget to share this with your friends, and consider subscribing to the OfficeDemy blog to get updates for the upcoming articles.