Table of Contents
One of the most powerful features within Excel is the ability to apply Conditional Formatting. This sophisticated tool allows users to automatically highlight data based on predefined criteria, transforming static spreadsheets into dynamic, visually informative dashboards. Specifically, situations often arise where data integrity or reconciliation requires immediate visual confirmation if two corresponding values are different—that is, if they are not equal.
To implement this specific rule—highlighting discrepancies between two cells—you must leverage the Formula option within the Conditional Formatting dialog box. This advanced method requires constructing a logical test using comparison operators, such as the “not equal to” operator (<>). The core process involves selecting the target range, creating a new rule, defining the logical formula that compares the first cell against the second, and then applying the desired visual styling, such as a specific fill color or font style, to make the mismatch instantly recognizable. This technique is indispensable for data auditing, list comparison, and quality control.
This guide will walk through the precise, step-by-step methodology required to set up this rule effectively. We will explore how to structure the logical formula correctly, paying close attention to absolute and relative cell referencing, which is paramount for ensuring the formatting rule applies correctly across entire rows or columns, and examine how to handle complex scenarios, including those requiring case-sensitive comparisons.
It is exceptionally common in data management and analysis to need immediate identification of inconsistencies. You may be comparing budgeted figures against actual expenditures, verifying data entry across multiple sources, or reconciling two separate lists. Applying Conditional Formatting if two cells in Excel contain unequal values is the most efficient visual method for achieving this goal. This proactive approach significantly speeds up error correction and assures data quality.
The subsequent sections detail a comprehensive example demonstrating the precise procedure for setting up this inequality check using a custom formula rule. Mastering this technique greatly enhances data auditing capabilities and reduces the manual effort required for discrepancy detection, particularly when dealing with large datasets where manual cell-by-cell verification is impractical or prone to human error.
Understanding the “Not Equal To” Operator in Excel
Before implementing the rule, it is essential to understand the underlying logic used in Excel formulas. When we want to check if two values are different, we use the “not equal to” comparison operator, represented by the symbols <>. When used in a logical test, this operator evaluates the comparison and returns TRUE if the values on either side are numerically or textually distinct, and FALSE if they are identical.
In the context of Conditional Formatting, we build a formula that incorporates this operator. If the formula evaluates to TRUE for any given cell within the selected range, the predefined formatting rule is applied to that cell or row. Conversely, if the formula evaluates to FALSE, indicating the cells are equal, the default formatting remains unchanged.
For example, if we are comparing the contents of cell A2 and cell B2, the formula =A2 <> B2 acts as the logical condition. If A2 contains “Apple” and B2 contains “Orange,” the condition is TRUE, and the formatting applies. If both contain “Apple,” the condition is FALSE, and no formatting is applied. This fundamental principle of logical evaluation governs the success and consistency of the entire conditional formatting operation when applied across a wide range of data.
Example: Conditional Formatting if Two Cells Are Not Equal
Consider a practical scenario where an organization maintains two separate lists—perhaps representing student enrollments in two different classes or inventory levels reported by two different departments. We need to quickly verify that the lists are identical row by row based on a key identifier, such as a name. Any mismatch needs immediate highlighting to facilitate investigation and correction. Suppose we have the following lists structured in columns A and B of an Excel spreadsheet:

Our objective is to highlight the cells in columns A and B whenever the name in column A does not match the name in column B for the corresponding row. This visual confirmation system is essential for ensuring data synchronization and pinpointing discrepancies efficiently, especially when dealing with data reconciliation across systems or manual entry comparisons. This demonstration uses student names, but the technique is universally applicable to numbers, dates, or other text strings.
The application of Conditional Formatting using a custom formula allows us to achieve this dynamic highlighting based on the comparison of values in cells A2 and B2, A3 and B3, and so on, throughout the specified range.
Step-by-Step Implementation of the Inequality Rule
To begin the process of dynamic highlighting, we must first define the range where the formatting rule will be applied. For this example, we wish to apply the highlighting across the entire data set, starting from the first data row (row 2) down to row 11 in both columns A and B. It is crucial to select the range accurately before navigating to the Conditional Formatting menu, as the formula written subsequently will be interpreted relative to the top-left cell of this selection.
- Select the Range: Highlight the target cells, specifically the range A2:B11. This selection determines the boundary where the visual formatting rule will be active.
- Access Conditional Formatting: Navigate to the Home tab on the Excel ribbon, locate the Styles group, and click the Conditional Formatting icon.
- Create a New Rule: From the dropdown menu that appears, select New Rule…. This action opens the crucial New Formatting Rule dialog box, which allows for the definition of custom rules.
The selection of the rule type is the next critical step. Since we are defining a complex logical condition based on a comparison between two different cells—a comparison that must adjust row-by-row—we must choose the formula-based rule type. Select Use a formula to determine which cells to format. This provides the necessary flexibility to use complex logical expressions and comparison operators like <> combined with specific cell referencing.

Defining the Formula and Referencing for Range Application
Once the formula input box is active, the logical test must be written with careful attention to absolute and relative cell referencing. Since the formatting rule is created only once but must be applied repeatedly across many rows, the formula must effectively “move” down the rows while keeping the columns fixed for comparison.
The formula focuses on the first row of your selected data (row 2) but utilizes a mixed reference. We use the dollar sign ($) to lock the columns (A and B) but omit it from the row number (2). This structure tells Excel: “For every cell in the range, check if the value in Column A of the current row is unequal to the value in Column B of the current row.”
Input the following formula into the designated box:
=$A2 <> $B2
The inclusion of $A2 and $B2 ensures that the column reference is absolute, guaranteeing that a cell in column A is always compared to a cell in column B. Leaving the row number relative (without a preceding dollar sign) allows the formula to automatically adapt as it is applied to subsequent rows, evaluating =$A3 <> $B3 for row 3, and =$A4 <> $B4 for row 4, and so on. This mechanism is vital for applying a single conditional rule to an entire data table effectively.
Applying Visual Formatting and Finalizing the Rule
With the inequality formula correctly established, the final step is to define the visual appearance that will signify a discrepancy. Click the Format… button located within the New Formatting Rule dialog box. This action opens the Format Cells window, which provides comprehensive options for customization.
Within the Format Cells window, focus primarily on the Fill tab. This is where you select a background color that will instantly draw attention to the mismatched data points. Selecting a vivid color (such as bright yellow, red, or orange) ensures maximum visibility. Additionally, you may choose to modify the text style using the Font tab—for instance, making the text bold or changing its color to reinforce the visual alert.

After selecting and confirming the desired formatting style, click OK in the Format Cells window, and then click OK again in the New Formatting Rule window. Excel will immediately process the rule across the selected range A2:B11, highlighting all rows where the values in column A and column B do not match based on the defined =$A2 <> $B2 formula. The resulting spreadsheet will clearly delineate the discrepancies, allowing for rapid review and correction of the lists:

Addressing Case Insensitivity in Standard Comparison
It is critically important to understand a key default behavior of the standard inequality operator (<>) when working with text strings in Excel. By default, Excel performs comparisons in a case-insensitive manner. This means that when the standard formula =$A2 <> $B2 is evaluated, it considers text strings that differ only in capitalization, such as “john” and “John,” to be equal values. Consequently, the rule will return FALSE for such pairs, and no highlighting will be applied, even though the capitalization differs.
For most operational data reconciliation tasks, this case-insensitivity is acceptable, as users are typically concerned with the underlying data content rather than the precise capitalization. However, in sensitive data environments requiring strict adherence to capitalization—such as verifying system identifiers, specific product SKUs, or standardized codes where case matters—relying solely on the <> operator will lead to missed discrepancies and potential data integrity issues.
To overcome this limitation and enforce a strict, character-by-character comparison, we must incorporate specific text functions into our Conditional Formatting formula. This technique necessitates using the EXACT function, which is inherently case-sensitive, designed specifically for meticulous text comparisons.
Implementing Case-Sensitive Inequality Checks using EXACT and NOT
To implement a truly case-sensitive comparison for inequality in Conditional Formatting, we utilize the EXACT function combined with the logical NOT function.
- The EXACT function (
EXACT(text1, text2)) compares two text strings and returns TRUE only if they are absolutely identical, including capitalization, spacing, and formatting. If they differ in any minute way (e.g., “Product A” vs. “product a”), it returns FALSE. - Since our goal is to highlight when the cells are NOT equal, we must invert the logical result returned by the EXACT function. This inversion is accomplished using the NOT function (
NOT(logical_value)).
If EXACT($A2, $B2) returns TRUE (meaning they match perfectly), applying NOT makes the final result FALSE, ensuring no formatting is applied. Conversely, if EXACT($A2, $B2) returns FALSE (meaning they are different, potentially only by case), applying NOT makes the final result TRUE, thus triggering the conditional highlighting. This combination successfully translates a case-sensitive equality check into a robust case-sensitive inequality trigger.
To apply a case-sensitive inequality search to the chosen range, replace the original formula with the following structure, ensuring the mixed cell references are maintained:
=NOT(EXACT($A2,$B2))
This advanced formula ensures that discrepancies resulting purely from capitalization inconsistencies are also flagged by the Conditional Formatting rule, providing a much higher level of scrutiny for sensitive data validation tasks and offering complete control over how text strings are compared within your spreadsheet environment.
Troubleshooting Common Conditional Formatting Issues
While the process of applying conditional formatting based on inequality is generally straightforward, users frequently encounter issues that prevent the highlighting from applying correctly or consistently. Understanding and addressing these common pitfalls is essential for effective data manipulation and validation.
One primary issue revolves around Incorrect Cell Referencing. If the formula is entered using fully relative references (e.g., =A2 <> B2) and the range A2:B11 is selected, Excel interprets the rule relative to the top-left cell of the selection. When checking cell B2, it might compare B2 to C2 (one cell to the right) and A2 (one cell to the left), leading to incorrect comparisons. This is resolved by using the mixed reference =$A2 <> $B2, which locks the comparison to columns A and B, regardless of which cell in the range is being evaluated.
Another common problem is Data Type Mismatch. If one cell contains a number formatted as text (often left-aligned) and the corresponding cell contains the same number formatted as a true numeric value (often right-aligned), Excel often treats them as unequal, triggering the formatting rule incorrectly. Always ensure data types are consistent. If necessary, use functions like VALUE() or TEXT() within the conditional formatting formula to standardize the comparison data before running the check, thereby preventing false positives.
Finally, Rule Overlap and Priority can mask discrepancies. If multiple Conditional Formatting rules apply to the same range, the priority order matters. If a higher-priority rule evaluates to true and has the “Stop If True” option checked, the inequality rule will never be checked. Always review the “Manage Rules” dialog box to ensure that the inequality rule is properly ordered and executed without being prematurely suppressed by another formatting criterion.
Cite this article
stats writer (2025). How to Highlight Differences Between Two Cells Using Conditional Formatting. PSYCHOLOGICAL SCALES. Retrieved from https://scales.arabpsychology.com/stats/how-to-apply-conditional-formatting-if-two-cells-are-not-equal/
stats writer. "How to Highlight Differences Between Two Cells Using Conditional Formatting." PSYCHOLOGICAL SCALES, 30 Nov. 2025, https://scales.arabpsychology.com/stats/how-to-apply-conditional-formatting-if-two-cells-are-not-equal/.
stats writer. "How to Highlight Differences Between Two Cells Using Conditional Formatting." PSYCHOLOGICAL SCALES, 2025. https://scales.arabpsychology.com/stats/how-to-apply-conditional-formatting-if-two-cells-are-not-equal/.
stats writer (2025) 'How to Highlight Differences Between Two Cells Using Conditional Formatting', PSYCHOLOGICAL SCALES. Available at: https://scales.arabpsychology.com/stats/how-to-apply-conditional-formatting-if-two-cells-are-not-equal/.
[1] stats writer, "How to Highlight Differences Between Two Cells Using Conditional Formatting," PSYCHOLOGICAL SCALES, vol. X, no. Y, ص Z-Z, November, 2025.
stats writer. How to Highlight Differences Between Two Cells Using Conditional Formatting. PSYCHOLOGICAL SCALES. 2025;vol(issue):pages.
