## Highlight opposite numbers

Pamela asks:

Ex. 1 with -1, 5000 with -5000, 75 with -75, etc.

Once I find those pairs, WITHOUT REPEATING

Ex. 75,-75,75, just the first TWO should get marked, and leave the last 75 alone.

Conditional formatting formula applied to cell range B3:B17:

### Explaining CF formula in cell B3

COUNTIF($B$3:B3, B3)=1

The first COUNTIF function counts how many values there are in the first argument that match the second argument.

It returns TRUE if it is equal to 1, meaning this is the first instance of the value. In other words, this makes sure that duplicates are not highlighted.

The first argument is also a growing cell reference, the picture below shows what it returns in column D:

COUNTIF($B$3:B3, B3*-1)

The second COUNTIF function counts how many values there are in the first argument matching B3 but with a different sign, starting from the top.

This verifiesÂ that there is a number withÂ a different sign above the current value.

The first argument has a growing cell reference meaning it expands as you copy the formula to cells below. In this case, I am using it as a Conditional Formatting formula, however, it behaves the same.

The picture below shows what it returns in columnÂ C:

MATCH(B3*-1,$B$3:$B$17,0)

The MATCH function looks for the number but with a different sign, this verifies it really exists a pair in the first place.

The MATCH function returns a #N/A error if a number is not found

COUNT(MATCH(B3*-1,$B$3:$B$17,0))

The COUNT function then converts error to a 0 (zero). The picture below shows what it returns in columnÂ E:

Then the formula adds the numbers in the two last arrays, like thisÂ COUNTIF($B$3:B3, B3*-1)+COUNT(MATCH(B3*-1, $B$3:$B$17, 0)

and lastly multiplies withÂ COUNTIF($B$3:B3, B3)=1.

### Get Excel *.xlsxÂ file

Matching opposite numbers.xlsx

### Recommended reading

### Built-in conditional formatting

Data Bars Color scales Icons### Highlight cells rule

Highlight cells containing stringHighlight a date occuring

Highlight cells equal to

Highlight unique/duplicates

### Top bottom rules

Highlight top 10 valuesHighlight top 10 % values

Highlight above average values

### Basic CF formulas

Working with Conditional Formatting formulasFind numbers in close proximity to a given number

Highlight empty cells

Highlight text values

### Search using CF

Highlight records – multiple criteria [OR logic]Highlight records [AND logic]

Highlight records containing text strings (AND Logic)

Highlight lookup values

### Unique distinct

How to highlight unique distinct valuesHighlight unique values and unique distinct values in a cell range

Highlight unique values in a filtered Excel table

Highlight unique distinct records

### Duplicates

How to highlight duplicate valuesHighlight duplicates in two columns

Highlight duplicate values in a cell range

Highlight smallest duplicate number

Highlight more than once taken course in any given day

Highlight duplicates with same date, week or month

Highlight duplicate records

Highlight duplicate columns

Highlight duplicates in a filtered Excel Table

### Compare

Highlight missing values between to columnsCompare two columns and highlight values in common

Compare two lists of data: Highlight common records

Compare tables: Highlight records not in both tables

How to highlight differences in price lists

Compare two columns and highlight differences

### Min max

Highlight smallest duplicate numberHow to highlight MAX and MIN value based on month

Highlight closest number

### Dates

Highlight dates in a date rangeHow to highlight MAX and MIN value based on month

Highlight odd/even months

Highlight overlapping date ranges using conditional formatting

Highlight records based on overlapping date ranges and a condition

Highlight date ranges overlapping selected record [VBA]

How to highlight weekends [Conditional Formatting]

How to highlight dates based on day of week

Highlight current date

### Misc

Highlight every other rowDynamic formatting

How to change cell formatting using a Drop Down list

Highlight cells based on ranges

Highlight opposite numbers

Highlight cells based on coordinates

### Excel categories

### Leave a Reply

### How to comment

**How to add a formula to your comment**

<code>Insert your formula here.</code>

**Convert less than and larger than signs**

Use html character entities instead of less than and larger than signs.

< becomes < and > becomes >

**How to add VBA code to your comment**

[vb 1="vbnet" language=","]

Put your VBA code here.

[/vb]

**How to add a picture to your comment:**

Upload picture to postimage.org or imgur

Paste image link to your comment.

**Contact Oscar**

You can contact me through this contact form