How to Match Positive and Negative Values Using Excel Conditional Formatting
Question details
The user needs to set up a conditional formatting rule to correctly identify and highlight matching number pairs where one value is positive and the corresponding value is negative.

- Product
- Excel
- Device & OS
- not provided
- Scenario
- Reconciling data where positive and negative amounts need to offset each other, requiring visual confirmation of matched pairs.
- Observed behavior
- Basic conditional formatting rules only highlighted values based on being greater or less than zero, without actually confirming if the exact opposite matching value existed in the dataset.
Ensure that your target data range contains purely numeric values, and remove any hidden spaces or text formats that might prevent the formulas from accurately reading the numbers.
Use Formula-Based Conditional Formatting (Recommended)
Apply a custom COUNTIF and ABS formula to check if the exact opposite value exists within the same range, highlighting all valid pairs in a shared color.
Standard conditional formatting presets cannot compare matching positive and negative numbers. By using a formula rule, you can command Excel to check the absolute values in the range and verify if an opposing positive or negative number is present.
Highlight the cells containing the amounts you want to match, for example, cells B2 through B100.
Go to the 'Home' tab on the ribbon, click on 'Conditional Formatting', and select 'New Rule'.
Click on 'Use a formula to determine which cells to format' from the list of rule types.
In the formula bar, enter: =COUNTIF($B$2:$B$100,-ABS(B2))+COUNTIF($B$2:$B$100,ABS(B2))>0 (adjust the range $B$2:$B$100 to match your actual data layout).
Click the 'Format' button, choose a fill color to highlight your matching pairs, and click 'OK' to apply the rule.

Use VBA Macro for Unique Matching Colors
If you require every unique matching pair to be highlighted in a completely different color, you must use a VBA macro instead of standard conditional formatting.
Highlight Matching Values Easily in WPS Spreadsheet
WPS Spreadsheet fully supports advanced conditional formatting formulas, allowing you to seamlessly use COUNTIF and ABS functions to reconcile positive and negative data without requiring complex add-ins.
- 1. Open your workbook: Launch WPS Spreadsheet and open your financial or data document containing the values.
- 2. Select your data: Highlight the column or range of numbers you want to analyze for matching pairs.
- 3. Create a new rule: Navigate to the Home tab, click 'Conditional Formatting', and select 'New Rule'.
- 4. Apply the formula: Choose 'Use a formula to determine which cells to format', enter your formula, pick a fill color, and click OK.

Frequently Asked Questions
Why did my previous conditional formatting rule highlight numbers without matching them?
Basic predefined rules, such as 'Greater Than' or 'Less Than' zero, simply check each cell individually against zero. They do not cross-reference the rest of your data to ensure an exact offsetting opposite value exists.
Does this formula work if there are multiple duplicate values?
If there are duplicate values (for example, two 50s and one -50), the COUNTIF formula will highlight all three cells. To match them exactly 1-to-1 and leave the extra unpaired value unhighlighted, you would need to set up helper columns or utilize a custom VBA macro.
Can I automatically delete the highlighted matched pairs?
Conditional formatting only changes the visual appearance of cells. To remove the matched pairs, you can filter your data by the conditional formatting color and delete the visible rows, or use a Power Query setup to filter out values that sum to zero.




