How to Automatically Return an ID from a Drop-Down Selection in Excel
Question details
The user wants to retrieve a specific ID dynamically when selecting an item name from a drop-down list, with the ability to add optional criteria such as country.

- Product
- Excel
- Device & OS
- not provided
- Scenario
- Setting up an interactive data entry form or invoice where selecting a product, brochure, or promotional item from a drop-down list automatically populates its unique ID.
- Observed behavior
- Need a formula-based solution to link a selected name and country to its unique ID without manually typing the ID each time.
Ensure your source data containing the brochure names, countries, and IDs is organized in a clear tabular format, preferably formatted as a Table (Ctrl+T) so your formulas can update dynamically when new items are added.
Use XLOOKUP for a Multi-Criteria Selection
Use this method when the ID depends on multiple conditions, such as matching both the selected brochure name and the chosen country.
XLOOKUP allows you to evaluate multiple criteria by multiplying conditions together. This creates a boolean array where only the row matching all criteria equals 1.
Select the cells where users will input data. Go to the Data tab, click Data Validation, choose 'List', and select your brochure names and countries ranges.
Click the cell where you want the ID to appear. Enter the formula: =XLOOKUP(1, (BrochureNames=SelectedBrochure)*(Countries=SelectedCountry), IDs, "Not found").
Replace 'BrochureNames', 'Countries', and 'IDs' with the actual column ranges of your source data. Replace 'SelectedBrochure' and 'SelectedCountry' with the cells containing your drop-down lists.
Press Enter. The cell will now automatically display the correct ID when both criteria are met in the drop-down menus.

Use XLOOKUP for a Single Criteria Selection
This is the most efficient way to return an ID if it only depends on a single drop-down selection.
Use INDEX and MATCH as an Alternative
If you are using an older spreadsheet version that does not support the XLOOKUP function, use a combination of INDEX and MATCH.
Easily Automate Data Lookups with WPS Spreadsheet
WPS Spreadsheet provides robust support for advanced data lookup functions like XLOOKUP, Data Validation, and dynamic arrays. You can seamlessly build interactive templates, track inventory, and retrieve data without writing complex VBA code.
- 1. Open your dataset in WPS Spreadsheet: Launch WPS Office and open your workbook containing the brochure data.
- 2. Insert the function easily: Go to the 'Formulas' tab and click 'Insert Function' to search for XLOOKUP, providing a user-friendly interface to set arguments.
- 3. Build dynamic drop-downs: Navigate to the 'Data' tab and use the 'Validation' feature to quickly assign list sources for your input cells.

Frequently Asked Questions
Why does my XLOOKUP formula return a #N/A error?
This usually happens if the selected brochure name in the drop-down does not exactly match the name in your source data table. Check for hidden leading or trailing spaces. You can also specify an 'If not found' value in the 4th parameter of XLOOKUP to display a custom text instead of an error.
How do I make the drop-down list update automatically when I add new brochures?
Convert your source data range into an official Table by selecting the data and pressing Ctrl+T. When you use the table column reference (e.g., Table1[BrochureName]) in your Data Validation settings, the drop-down list will automatically include new entries.
Can I use VLOOKUP instead of XLOOKUP for this?
Yes, you can use VLOOKUP for a single-criterion lookup, provided the ID column is located to the right of the Brochure Name column in your source data. However, for multi-criteria lookups (like Name and Country), XLOOKUP or INDEX/MATCH are significantly more reliable.
What if multiple countries have the same brochure but different IDs?
You must use the multi-criteria lookup method. By multiplying the criteria arrays like (BrochureNames=Name)*(Countries=Country), the formula creates a unique condition that isolates the exact row matching both attributes to return the correct ID.




