Google Sheets

How to Create a Drop-Down List in Google Sheets

How to Create a Drop-Down List in Google Sheets

There are a few ways to create a drop-down list in Google Sheets. One way is to use the Data Validation tool. To do this, select the cells you want to use for the drop-down list and go to Data > Validation. In the Validation window, select "List" from the "Allow" drop-down menu. Then, in the "Source" field, enter the list of items you want to appear in the drop-down list. You can also specify the order of the items in the list by entering them in the "List Order" field.

Another way to create a drop-down list is to use the Data Validation tool in conjunction with a Google Sheets script. To do this, select the cells you want to use for the drop-down list and go to Tools > Script Editor. In the Script Editor window, paste the following code into the "Code" tab:

function createDropdown(source) {

var sheet = SpreadsheetApp.getActiveSheet();

var data = sheet.getRange(source.offset().left, source.offset().top).getValues();

var options = [];

for (var i = 0; i < data.length; i++) {

options.push(data[i][0]);

}

return options;

}

Then, go to the "Resources" tab and click on "Add Library". In the "Library window, select "Google Sheets Add-ons" and then "Data Validation". Click on the "Install" button and then the "Close" button.

Back in the Script Editor window, paste the following code into the "Code" tab:

var sheet = SpreadsheetApp.getActiveSheet();

var data = sheet.getRange(source.offset().left, source.offset().top).getValues();

var options = createDropdown(data);

sheet.setRange(source.offset().left, source.offset().top, options);

}

This code will create a drop-down list based on the data in the specified range.

Finally, to run the script, go to the "File" menu and select "Save". Then, go to the "Tools" menu and select "Scripts". In the "Scripts window, select "createDropdown" and click on the "Run" button.

Move beyond 

Google Sheets

Get started with Causal today.
Build models effortlessly, connect them directly to your data, and share them with interactive dashboards and beautiful visuals.