How to Insert Radio Button in Google Sheets (Best Practice)

Google sheets radio button

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.

See also  How to Apply Google Sheets Conditional Formatting If Cell Contains Formula

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

google-sheets-radio-button-1

google-sheets-radio-button-2

Step 2

Go to tools > script editor.

Or

Go to extension > Apps Script

See also  How to Stop Rounding Numbers in Google Sheets (2 Methods)

google-sheets-radio-button-3

Step 3

In the script editor below, copy and paste the script provided below in this article

google-sheets-radio-button-4

 

Step 4

Now run the code to authorize the script

google-sheets-radio-button-5

Step 5

Go back to the google sheets to see the google sheets radio buttons are added and working properly

google-sheets-radio-button-8

 

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.

google-sheets-radio-button-7

 

To recap, you need to learn how to script works, even if don’t understand coding? You should understand the concept behind the code, and this will be enough for you to make little changes to the code and customize your checkboxes according to your need. It’s simple just you need to go through the code and try to read them, it’s easy and you will get it for sure. Secondly, it’s important to understand the feature of selecting multiple options at a time. In many cases, you need this feature, and many times you don’t, so understand this feature and use it accordingly.

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

See also  How to Use Absolute and Relative Cell References in Google Sheets

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.

Content Protection by DMCA.com

M. Shaiq Ansari

Hi, I am Shaiq. A young and self-motivated content writer having years of experience expertise in MS Office suite, Google docs Editor Suite. I have a technical education background that empowers me to stand out in today's digital world. I am currently a freelance content creator and a part of a local digital marketing agency in Karachi Pakistan.

OfficeDemy.com
Logo
Enable registration in settings - general