In this article we will show how to give a list of checkboxes the same functionality as radio buttons in google sheets with apps script.
First, format the sheet and add checkboxes in the process. For example, we have the following sheet below where we will add checkboxes to the range B2:E6.
To add the checkboxes, select the range.
After selecting the range, click Insert then select Checkbox.
The checkboxes are now inserted.
By default, you can tick two or more checkboxes along the same row at the same time. We want to modify this behavior by using a custom script to, thus making Google Sheets clear the other checkboxes when a new one along the same row is ticked. This will give us the same functionality as a radio button in our google sheet.
We insert the script through Google Apps Script. Click Extensions, then select Apps Script.
A new tab will load containing Google Apps Script.
Copy the following script, taken from Ben Collins:
Go to the Apps Script tab, clear the code area, then paste the script.
Click the Save project button.
We can now run the script. Click Run the selected function.
The Execution log will appear, and you will get an error. It is fine.
Go back to the tab containing the Google Sheet, and start ticking the checkboxes. You will notice that when you tick another checkbox along a row with a checkbox already ticked, the previously-ticked checkbox will be unchecked.
Congratulations! You are able to implement the script very well.
Let’s say you want to add choices on Columns B, C, and D only. You only need to modify the script a bit. You can copy the script below:
The script can be copied from the link below:
https://github.com/rvbautista/radio-buttons-google-sheets/blob/main/README.md
And you will get the following result:
Then you need to edit the script itself. Check the link below for a guide to editing the script to accommodate other columns.
https://github.com/rvbautista/radio-buttons-google-sheets/blob/main/README.md
We hope this article has helped you and given you a better understanding of how to add radio buttons in Google Sheets. You might also like our articles on how to make a button in Google Sheets and how to use Google Sheets named ranges.
To optimize your workflow, we recommend reading our guide on how to attach a Google Sheet to an email.