In this post, you’ll learn how to set default values for cells in Google Sheets, without using Google Apps Script code.
In the Sheet below, the cells in column B have default values of 100, 25, and 10 respectively. If a user types in a value (e.g. 200) it overwrites the default value. If a user deletes whatever value is in the cell already, then the default value of 100 is displayed again.
Setting Default Values For Cells In Google Sheets
The key to make this technique work is to use Array Literals to create a formula which spills into the adjacent cell. This is a rather abstract concept, so let’s run through an example.
In a blank Sheet, write the value “Input” in cell A1. In cell B1, type this formula:
Your Sheet will look like this:
Try typing 200 in cell C1, over the top of the 100.
Cell C1 will show the 200, but cell B1 now displays a #REF! error.
Now, delete the value you just typed in cell C1. The error message disappears and the default value of 100 is displayed again.
Finally, hide column B so that the #REF! error is never seen, and you have a default value of 100 set for cell C1.
🎩 Hat tip to my friend Scott Ribble for showing me this ingenious solution.
Advanced Default Values Without Hidden Column
The method above suffers from one drawback though: it necessitates a hidden column.
However, we can use a clever circular formula to address this.
In a new blank Sheet, add this formula in cell A1:
Initially, you may see this error message about a circular error (i.e. a formula that references itself):
That is a problem, but we fix it by switching on iterative calculations and restricting them to a single iteration from the menu:
File > Settings
Go to “Calculation”.
Set “Iterative calculation” to “On” and the “Max number of iterations” to 1.
(The threshold can be left at 0.05 because it doesn’t apply in this case.)
Now, you can enter any value you want in cell B1 and if you delete it, the default value of 100 will be shown.
How Does This Work?
The IF function checks whether cell B1 is blank.
If it is blank, then it outputs the array literal:
which displays “Input” in cell A1 and the value 100 in cell B1.
However, if cell B1 already has a value then the IF function output is just the string “Input” in cell A1.
Note: default values are not limited to numbers. It could be text, an image, or even another formula.
Default Values Checkbox Example
You can use default values to check or uncheck checkboxes. Here’s a cool illustration of how to create a select all checkbox in Google Sheets, using deafult values.
Thanks to one of the readers in the comments below for sharing this solution.
Default Values Formulas To Mimic Radio Buttons
Another interesting use case for these default values is to mimic radio buttons with formulas and checkboxes.
Column A contains array literal formulas that ensure a user can only select a single checkbox at a time.