How to set conditional formatting in Excel to change colors based on values greater than, less than, or equal to a certain number
Explain the steps for setting up conditional formatting in Excel to change colors based on “greater than,” “less than,” “equal to,” “not equal to,” and “equal to 0.” Cover how to choose Highlight Cells Rules, Other Rules, and Custom Formulas, and provide verification methods to help you automate color changes for values.
If you’re working with sales sheets, grade reports, or budgets in Excel, you often want numbers to turn red automatically when they exceed a certain threshold and gray when they fall below a specific value. This requires using conditional formatting. Many people search for"Excel conditional formatting greater than or less than,"but they usually get stuck in one of two places: they don’t know where to find the feature, or they’re unsure how to choose comparison operators like"greater than or equal to"or"not equal to."
This article covers only the rules for comparing cell values, including greater than, less than, equal to, not equal to, greater than or equal to, less than or equal to, and"change color when equal to 0."By the end, you’ll be able to set up color‑based rules for an entire column of numbers and know when to switch from cell‑value rules to formula‑based ones.
How to set up conditional formatting in Excel for greater than or less than? One-sentence conclusion
In most cases, simply select the data range and use the Highlight Cells Rules > Greater Than, Less Than, or Equal To options; you only need to switch to a formula when the comparison criteria are more complex. The table below can help you quickly identify the appropriate approach.
| Your situation | Recommended Practice | Reason |
|---|---|---|
| Compare with a fixed number, such as greater than 20. | In the Highlight Cells Rules, select Greater Than and enter 20. | Fewer setup steps, with rules easy to read at a glance |
| Greater than or equal to, less than or equal to, or not equal to is required. | Select"Cell Value"in Other Rules, then choose the corresponding comparison operator from the dropdown. | These items are missing from the highlighted rules list. |
| The threshold is written in another cell, such as B1. | Enter $B$1 in the cell value box. | Colors update automatically when the threshold is changed. |
| To compare two columns, such as when column C is greater than column D | Use a formula rule to change the color when the formula evaluates to TRUE. | A cell value rule can only compare one cell with a single value. |
| The number is actually in text format. | Convert to numeric values first, then set the rules. | Text is not included in the case comparison, and the rule will be disabled. |
Before You Begin: First, Confirm These Points
First, verify whether the data is numeric or text. Numbers copied from web pages or other systems are often stored as text. They are typically left-aligned, and a green triangle may appear in the upper-left corner of the cell. Such numbers are not recognized by sorting rules, their color will not display, and any formatting settings will be ineffective.
Identify the item you’re comparing it to. Whether it’s a fixed number, another cell, or another column in the same row determines which rule you should use. Getting this clear can save you a lot of trouble.
Choose the correct range. Select only the column or block you want to evaluate—for example, C2 to C200—rather than the entire sheet. In formula rules, relative references are based on the top-left cell of the selected range; if the starting point of the selection is off, the formula will shift incorrectly.
Be mindful of blank cells. In cell value rules, blank cells are sometimes treated as 0 in comparisons, and"equals 0"may also flag spaces. If the table contains many blank rows, first determine whether they need to be excluded.
Check if rules already exist. If a rule has already been set for the same area, the new rule may overlap with the old one, causing colors to overwrite each other. Before setting up, open the rule management panel to see what’s already configured for that area.
Steps to Set Color Changes for Greater Than, Less Than, Equal To, and Not Equal To
- Select the data range you want to evaluate, for example, C2 to C200.
- Go to the Home tab, find Conditional Formatting, and open its drop-down menu.
- Choose Highlight Cells Rules; if you only need Greater Than, Less Than, or Equal To, click the corresponding option directly.
- In the dialog box that appears, enter the threshold on the left—e.g., 20—and choose a fill color or font color on the right, then click OK.
- If you need Greater Than or Equal To, Less Than or Equal To, or Not Equal To, select "More Rules" at the bottom of the menu, open "New Formatting Rule," and choose "Format only cells that contain."
- In the Cell Value drop-down, select the appropriate comparison operator, enter the value, set the color, and click OK. For example, to change the color when equal to 0, select "Equal To" and enter 0.
- If the threshold should change based on another cell, enter that cell’s absolute address in the value box—for example, $B$1—locking both the row and column to prevent address offsets when copying the rule.
- After confirming, review the results. If the colors are in the wrong positions, return to Manage Rules to adjust the scope or delete any unnecessary rules.
Check each item after completion
| Check item | How do you see it? | What should I do if there’s a problem? |
|---|---|---|
| Is the border color correct? | Find a cell whose value is exactly equal to the threshold and check whether it has changed color. | If the one that should change color hasn’t, replace"greater than"with"greater than or equal to,"and vice versa. |
| Whether the text digits are recognized | Check whether it is left-aligned and whether there is a green triangle in the corner. | Use the Text to Columns feature to convert to numbers, or enter 1 in a blank cell, copy it, and then use Paste Special to multiply. |
| Did the blank cells change color by mistake? | Check if the blank square has a color. | Switch to using formula rules and write conditional checks like =AND(C2<>"",C2=0) |
| Are the rules redundant or conflicting? | Open the management rules to view the scope of application and sequence. | Remove duplicates, adjust priorities, and move the rules you need to the front. |
| Has the new data taken effect? | Add a line of numbers at the end and see if the color appears accordingly. | If the cell range is fixed, expand the scope of application, or switch to referencing entire columns. |
📊 Core Comparison
| Method | What can be compared? | Suitable scenarios |
|---|---|---|
| Highlight Cells Rules | Greater than, less than, equal to, between, etc.; the threshold is a fixed number. | Quickly highlight values that are above or below a certain number |
| Cell values in other rules | Additional support for greater than or equal to, less than or equal to, and not equal to; the threshold can reference a cell. | The comparison operators are quite comprehensive, and the threshold needs to vary with the table. |
| Official Rules | Arbitrary logical judgments, supporting cross-column and cross-row operations and combining multiple conditions. | Compare two columns, exclude blanks, and apply conditional formatting based on multiple criteria. |
Simply put, if you can achieve what you need with the first two methods, there’s no need to use a formula. Formulas are the better choice only when you need to combine conditions or compare across columns.
❓ Frequently Asked Questions (FAQ)
1. How can I set both a color change for values greater than or equal to a certain number and for values less than 0?
Create two separate rules. One uses"greater than or equal to"with the value 0 and applies one color; the other uses"less than"with the value 0 and applies another color. The two rules should not interfere with each other and can have the same scope.
2. How do you enter "not equal to" in conditional formatting?
In the"Cell Value"dropdown under Other Rules, select"Does Not Equal,"then enter the value directly—for example, 0—without adding a sign. If you also want to exclude blank cells, switch to a custom formula rule and incorporate a check for blanks into the formula.
3. How do you write a conditional formatting formula for cells to be greater than or less than a number?
After selecting the range, choose"Use a formula to determine which cells to format"in the New Formatting Rule. Assuming the selection starts at C2, write =C2>20 for values greater than 20 and =C2<20 for values less than 20. The C2 in the formula will adjust relative to each cell, so use the top-left cell of the selected range as the reference.
4. How do you highlight only the top few cells by value?
In conditional formatting’s"Set Ranking"rule, select the top N items or bottom N items and set the count to 1 to highlight only the value ranked first. These rules compare rankings rather than fixed thresholds, so the highlighting adjusts automatically when the data changes.
📝 Summary
Most cases of changing cell colors in Excel conditional formatting for greater than, less than, equal to, and not equal to can be handled using built-in highlighting rules or other rules. Before setting up, make sure your data is numeric, select the correct range, and decide whether to use a formula based on whether you need to apply the rule across columns or combine conditions. After completing the setup, perform spot checks on boundary values and blank cells to ensure everything works as expected.


