Formula for Conditional Formatting to match nos. in range

naira

New Member
Joined
May 7, 2013
Messages
16
Office Version
  1. 2013
Platform
  1. Windows
Hi!
My data is as given below:
Data in Row 1:
89 68 68 97 84 64 77 93 67 75 63 55 82 64

Data in Row 3:
87
62 63 69 72 90 51 70 78 91 71 63 88 52

Below formula is being used for conditional formatting of range A1:N1. The formula identifies and highlights a number in the range A1:N1 that is Exactly 5 more than any of the numbers in range A3:N3.
Excel Formula:
=COUNTIF($A$3:$N$3, (A1+$J$5))

However, I need to modify the formula so that I can highlight any number in range A1:N1 that is upto 5 more or upto 5 less of any other number in range A3:N3.
For example, in the above example, the numbers 68, 63 and 55 should also be highlighted since they fall within the range of nos. 62, 63, and 52 in row 3.

The range of the numbers to be checked is entered in Cell J5 in the above formula.

1641373114256.png


PS: I tried with ABS, and range functions but could not get them to work.
 

Excel Facts

Remove leading & trailing spaces
Save as CSV to remove all leading and trailing spaces. It is faster than using TRIM().
I suggest that you update your Account details (or click your user name at the top right of the forum) so helpers always know what Excel version(s) & platform(s) you are using as the best solution often varies by version. (Don’t forget to scroll down & ‘Save’)

If you have the FILTER function, try this.

22 01 05.xlsm
ABCDEFGHIJKLMN
18968689784647793677563558264
2
38762636972905170789171638852
4
55
CF Range
Cells with Conditional Formatting
CellConditionCell FormatStop If True
A1:N1Expression=COUNT(FILTER($A3:$N3,ABS($A3:$N3-A1)<=$J$5,""))textNO
 
Upvote 0
I suggest that you update your Account details (or click your user name at the top right of the forum) so helpers always know what Excel version(s) & platform(s) you are using as the best solution often varies by version. (Don’t forget to scroll down & ‘Save’)

If you have the FILTER function, try this.

22 01 05.xlsm
ABCDEFGHIJKLMN
18968689784647793677563558264
2
38762636972905170789171638852
4
55
CF Range
Cells with Conditional Formatting
CellConditionCell FormatStop If True
A1:N1Expression=COUNT(FILTER($A3:$N3,ABS($A3:$N3-A1)<=$J$5,""))textNO
Hi Peter,

Sorry, didn't know about that option. Have updated the data.

No, Filter function is not available to me. Could you please suggest something else.
 
Upvote 0
Have updated the data.
Thanks for that. (y)

Try this instead.

22 01 05.xlsm
ABCDEFGHIJKLMN
18968689784647793677563558264
2
38762636972905170789171638852
4
55
CF Range (2)
Cells with Conditional Formatting
CellConditionCell FormatStop If True
A1:N1Expression=SUMPRODUCT(--(ABS($A3:$N3-A1)<=$J$5))textNO
 
Upvote 0
Solution
Thanks for that. (y)

Try this instead.

22 01 05.xlsm
ABCDEFGHIJKLMN
18968689784647793677563558264
2
38762636972905170789171638852
4
55
CF Range (2)
Cells with Conditional Formatting
CellConditionCell FormatStop If True
A1:N1Expression=SUMPRODUCT(--(ABS($A3:$N3-A1)<=$J$5))textNO
Works Magically.
Thanks for your help @Peter_SSs.
 
Upvote 0
You're welcome. Thanks for the confirmation. :)
 
Upvote 0

Forum statistics

Threads
1,215,836
Messages
6,127,180
Members
449,368
Latest member
JayHo

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top