How to Write an Excel Formula to Match Values and Numeric Ranges
Question details
The user needs an Excel formula to check a condition in one column and verify if a related number in another column falls within specific ranges, returning custom results based on the match.

- Product
- Excel / WPS Spreadsheet
- Device & OS
- not provided
- Scenario
- Categorizing or returning specific labels based on a combination of exact text matches and numeric range conditions.
- Observed behavior
- Requires an automated way to output specific results (like 'Y' or 'Z') when both conditions (text match and numeric range) are met.
Determine your exact criteria for both the text match and the numeric boundaries. Note that the IFS function is available in newer versions of Excel and WPS Office; if you are using an older version, you will need to use nested IF functions.
Use the IFS and AND Functions (Modern Approach)
The most efficient way to handle multiple conditions and ranges in newer spreadsheet software.
The IFS function allows you to test multiple conditions without writing complex nested statements. By combining it with the AND function, you can evaluate both text matches and numeric ranges simultaneously.
Click on the cell where you want the final categorized result to appear.
Type the formula: =IFS(AND(A2="X", B2>=10, B2<=20), "Y", AND(A2="X", B2>21, B2<=30), "Z", TRUE, ""). Replace "X", "Y", "Z", and the numbers with your actual data criteria.
Press Enter to apply the formula, then click and drag the fill handle at the bottom right of the cell to copy the formula down to other rows.

Use Nested IF and AND Functions (Legacy Compatibility)
Use this method if you are working with older spreadsheet versions that do not support the IFS function.
Use WPS Spreadsheet for Advanced Formula Handling
WPS Spreadsheet fully supports advanced logical functions like IFS, IF, and AND, making it incredibly easy to manage complex data categorization. It offers a familiar interface and function wizard, ensuring your formulas work seamlessly without syntax errors.
- 1. Open your workbook: Launch WPS Spreadsheet and open the document containing your data.
- 2. Open the function wizard: Click on the 'Formulas' tab in the top ribbon and select 'Insert Function' to open the formula dialog box.
- 3. Configure the IFS function: Search for 'IFS', select it, and input your logical tests (using the AND function for ranges) and return values directly into the input fields.
- 4. Insert the formula: Click 'OK' to insert the error-free formula into your cell, then drag it down to apply to remaining rows.

Frequently Asked Questions
Why is my IFS formula returning an #N/A error?
An #N/A error in an IFS formula means that none of the conditions evaluated to TRUE, and no default catch-all condition was provided. To fix this, add TRUE as the final logical test, followed by your desired default value, such as TRUE, "Not Found".
Can I use the OR function instead of AND for checking ranges?
The AND function is required when you want a number to fall strictly between two boundary values (e.g., greater than 10 AND less than 20). If you use OR, the condition returns true if the number meets either requirement, which breaks the logic for an inclusive numeric range.
How many nested IF conditions can I use?
In modern versions of Excel and WPS Spreadsheet, you can nest up to 64 IF functions. However, if you find yourself nesting more than 4 or 5 conditions, it is highly recommended to use the IFS function or create a VLOOKUP/XLOOKUP reference table for better readability.
Does this formula work if my numeric range has decimals?
Yes, logical operators like >= and <= evaluate decimal numbers correctly. Just ensure your formula criteria match the precision you need (e.g., using B2>=10.5).




