How to Use Nested IF to Assign Company Size Categories in Excel
Question details
The user needs to write a formula using nested IF conditions to classify a numeric market cap value into a specific text category.

- Product
- Excel
- Device & OS
- not provided
- Scenario
- Categorizing financial data by assigning labels (Micro Cap, Small Cap, Mid Cap, Large Cap, Mega Cap) based on numeric thresholds in a cell.
- Observed behavior
- The user wants to correctly order the logical tests to avoid invalid comparisons and ensure the correct category is returned.
Ensure your market capitalization data is in a consistent numeric format (e.g., billions) before applying the nested IF formula, and verify the exact upper limit values for each tier.
Write an Ascending Nested IF Formula
Use a sequentially ordered nested IF statement to evaluate the value against the upper limit of each category from smallest to largest.
When using nested IF functions for value ranges, evaluate conditions in strict ascending order. This prevents logical errors, because Excel stops evaluating the formula as soon as it encounters the first TRUE condition.
To prevent blank cells from being incorrectly categorized as a small number (like Micro Cap), it is best practice to wrap the formula in an ISBLANK check.
Click on the cell where you want the company size category text to appear.
Type the formula: =IF(ISBLANK(B5),"",IF(B5<=0.3,"Micro Cap",IF(B5<=2,"Small Cap",IF(B5<=10,"Mid Cap",IF(B5<=200,"Large Cap","Mega Cap")))))
Press Enter to execute the formula. The cell will now display the correct category based on the value in B5.
Click the small square at the bottom-right corner of the cell and drag it down to apply the categorization to the rest of your dataset.

Use the IFS Function as a Modern Alternative
For newer versions of Excel and WPS Spreadsheet, use the IFS function to avoid complex nesting and improve formula readability.
Easily Categorize Data Using WPS Spreadsheet
WPS Spreadsheet provides full support for complex logical functions like IF and IFS. You can easily categorize financial data, build automated models, and handle large datasets seamlessly without worrying about syntax limitations.
- 1. Open your dataset: Launch WPS Spreadsheet and open the workbook containing your company data.
- 2. Enter the formula: Click on the target cell, navigate to the Formula Bar, and input your nested IF or IFS formula.
- 3. Auto-fill your table: Press Enter, then double-click the fill handle to instantly categorize thousands of rows in seconds.

Frequently Asked Questions
Why is my nested IF formula returning the wrong category?
This usually happens if the conditions are not in the correct ascending or descending order. Excel evaluates IF statements from left to right and stops at the first TRUE condition. Always test from smallest to largest (using <=) or largest to smallest (using >=).
How do I handle blank cells in a nested IF formula?
Wrap your main logic with a check for empty cells using the ISBLANK function. For example, starting your formula with =IF(ISBLANK(B5),"", ...) ensures that blank cells return an empty string instead of being treated as zero and incorrectly categorized as a small number.
Can I use VLOOKUP instead of a nested IF for categories?
Yes. For many categories, an approximate match VLOOKUP (setting the last argument to TRUE) is often cleaner than a long nested IF. You just need to set up a small reference table containing the lower bound of each tier and its corresponding label.
What is the maximum number of nested IFs allowed in Excel?
In modern versions of Excel and WPS Spreadsheet, you can nest up to 64 IF functions. However, if you are using more than 5 to 7 nested IFs, it is highly recommended to use the IFS function or a VLOOKUP reference table for better readability and easier maintenance.




