Question posted 2010 · +9 upvotes
In Excel (2003), I want to limit the selection of values in a cell to allowable values from another spreadsheet.
For example, in the sheet “Currencies” I have
EUR,1.1 GBP,1.0 USD,1.5
(That’s two columns, three rows)
In my main sheet I’d like to have a Currency column, in which the only allowable values are from column A in the Currencies sheet, i.e. the cell can contain only ‘EUR’, ‘GBP’, or ‘USD’. (Elsewhere I’ll be using that as a lookup to get the exchange rate, which is column B.)
How can I restrict the value in the cell? Having a dropdown like a windows combo box populated from the other sheet would be great.
Any answers using formulas, VBA, or whatever will be fine. Even a pointer to the relevant documentation would be great (I have looked, but I’m not sure what to look for).
Also helpful would be answers using LibreOffice, since I haven’t finalized the choice of spreadsheet program, but I thought I’d have a better chance getting an answer in Excel.
Accepted answer +13 upvotes
VBA isn’t necessary in this case. Use the built-in “Data Validation” feature.
Select the cell you want to add the combo box to, and choose Data, Validation.
Select “List” as the option, and either put a cell range in the “Source” box, or a comma-delimited list of values (if you want to hard-code it).
If the range you want to populate the list is located on another worksheet, you can’t refer to it using the standard =sheet2!a1:a4 style. You’ll have to create a named range, and refer to it by that name.
Top excel Q&A (6)
- Shortcut to Apply a Formula to an Entire Column in Excel +335 (2011)
- How should I escape commas and speech marks in CSV files so they work in Excel? +136 (2012)
- Convert xlsx to csv in linux command line +96 (2012)
- How to create a link inside a cell using EPPlus +50 (2011)
- IF statement: how to leave cell blank if condition is false ("" does not work) +44 (2013)
- T-SQL: Export to new Excel file +44 (2012)
excel solutions on this site
.