Modify a Conditional Formatting for highlighting values falling in Range

naira

New Member
Joined
May 7, 2013
Messages
16
Office Version
  1. 2013
Platform
  1. Windows
Hi,

I have data in multiple rows (Row 2 to Row 6) and columns (Col. A to Col. M).

Either of the 2 formulae given below are used for conditional formatting in Row 2. The formulae compare whether any of the cells in rows 3, 4, 5 and 6 contains the same value falling within a particular range of any of the cell values in row 2. If the condition is true, then the corresponding cell in row 2 is highlighted. The range (i.e. plus or minus from values in row 2) is defined in cell O2.

This is the preferred formula for use, since a single formula for conditional formatting can cover multiple rows. Would prefer if a solution can be provided for this Formula
Excel Formula:
 COUNT(MMULT(--(ABS(A2-$A$2:$M$6)<=$O$2),TRANSPOSE(COLUMN($A$2:$M$6)^0))^0)=ROWS($A$2:$M$6)

Excel Formula:
=AND(SUMPRODUCT(--(ABS($A3:$M3-A2)<=$O$2)),SUMPRODUCT(--(ABS($A4:$M4-A2)<=$O$2)),SUMPRODUCT(--(ABS($A5:$M5-A2)<=$O$2)),SUMPRODUCT(--(ABS($A6:$M6-A2)<=$O$2)))

The formulae work correctly as long as all the 5 rows have data in it (which is correct since I am using AND condition for validation). However, sometimes, one of the rows might be Blank or may contain Zero value.

In such condition, I want the formulae (AND operator) to ignore the rows containing blank or zero values and consider only the rows containing actual values for the purpose of validation. For example, in case row 5 is empty, then the formula should compare values in row 2, only with values in rows 3, 4 and 6, and if found true, then highlight the corresponding cells in row 2. Row 5 should be ignored.

Note: Sample file attached. Screenshot of sample data is given below.
Also, I had posted this request at ExcelForum.com Since no useful reply received there, I am posting the request here.

1. Sample data for First formula:

sample_2 formulae.xlsx
ABCDEFGHIJKLMNOP
1ABCDEFGHIJKLMRange
2869399795756957368657262722
386687484749063746678835357
480578482548086977759786562
593839182866182508779698084
681828779568096769998919282Check that the Conditional Formatting fails in case:
71. Delete all data in all cells in any of the rows in Col. A to M
82. Enter Zero in all cells in any of the rows from Col. A to M
9Formula:COUNT(MMULT(--(ABS(A2-$A$2:$M$6)<=$O$2),TRANSPOSE(COLUMN($A$2:$M$6)^0))^0)=ROWS($A$2:$M$6)
10
11TRUEFALSEFALSETRUEFALSEFALSEFALSEFALSEFALSEFALSEFALSEFALSEFALSE
12TRUEFALSEFALSETRUEFALSEFALSEFALSEFALSEFALSETRUEFALSEFALSEFALSE
13TRUEFALSETRUEFALSEFALSETRUETRUEFALSETRUEFALSETRUEFALSEFALSE
14FALSEFALSEFALSEFALSETRUEFALSEFALSEFALSETRUETRUEFALSETRUETRUE
15TRUEFALSETRUETRUEFALSETRUEFALSEFALSEFALSEFALSEFALSEFALSEFALSE
FORMULA 2
Cell Formulas
RangeFormula
A11:M15A11=COUNT(MMULT(--(ABS(A2-$A$2:$M$6)<=$O$2),TRANSPOSE(COLUMN($A$2:$M$6)^0))^0)=ROWS($A$2:$M$6)
Cells with Conditional Formatting
CellConditionCell FormatStop If True
A2:M6Expression=COUNT(MMULT(--(ABS(A2-$A$2:$M$6)<=$O$2),TRANSPOSE(COLUMN($A$2:$M$6)^0))^0)=ROWS($A$2:$M$6)textNO


1.JPG


2.JPG


3.JPG



Sample data for second formula:

sample_2 formulae.xlsx
ABCDEFGHIJKLMNO
1ABCDEFGHIJKLMRange
2869399795756957368657262722
386687484749063746678835357
480578482548086977759786562
593839182866182508779698084
681828779568096769998919282
FORMULA 1
Cells with Conditional Formatting
CellConditionCell FormatStop If True
A2:M2,O2Expression=AND(SUMPRODUCT(--(ABS($A3:$M3-A2)<=$O$2)),SUMPRODUCT(--(ABS($A4:$M4-A2)<=$O$2)),SUMPRODUCT(--(ABS($A5:$M5-A2)<=$O$2)),SUMPRODUCT(--(ABS($A6:$M6-A2)<=$O$2)))textNO
 

Excel Facts

What is =ROMAN(40) in Excel?
The Roman numeral for 40 is XL. Bill "MrExcel" Jelen's 40th book was called MrExcel XL.
Maybe
Excel Formula:
=SUM(SIGN(MMULT(--(ABS(A2-$A$2:$M$6)<=$O$2),TRANSPOSE(COLUMN($A$2:$M$6)^0))))=SUM(SIGN(MMULT(--($A$2:$M$6>0),TRANSPOSE(COLUMN($A$2:$M$6)^0))))
 
Upvote 0
Maybe
Excel Formula:
=SUM(SIGN(MMULT(--(ABS(A2-$A$2:$M$6)<=$O$2),TRANSPOSE(COLUMN($A$2:$M$6)^0))))=SUM(SIGN(MMULT(--($A$2:$M$6>0),TRANSPOSE(COLUMN($A$2:$M$6)^0))))

Hi!

Thanks for your reply.
Yes the formula works now with an error control, i.e. the conditional formatting works even if some row is blank or has zero value. But it is only working partly.
In the below data set, I have noticed following errors:

1. With the difference of 2, ideally nothing should be highlighted in the below data set, but 76 is being highlighted in row 1 and 147 and 75 in row 2. (it seems that Row 5 is being for calculations, since there are other data in rows 4 & 6 that fall close to 76 & 149.
2. In case I delete everything in row 5, then data around the values 76 & 149 are highlighted. (it seems that Row 5 is being ignored for calculations).
However, now additionally 83 (in cell G3 is highlighted for some reason).
3. In case I change value in cell E5 from 74 to 75, then all cells having value around 76 are properly highlighted.
4. In case I change value in cell I5 from 115 to 148, then all cells having value around 149 are properly highlighted.

Could you kindly see why the cells are not being highlighted properly?

sample_2 formulae.xlsx
ABCDEFGHIJKLMNO
1ABCDEFGHIJKLMRange
21017611381144120146122116551081441492
3113971331296162831121477512714057
41299681771491001221261501059013858
5669314380741299512911511110014560
6771401501191381291421009512785125149
FORMULA 2
Cells with Conditional Formatting
CellConditionCell FormatStop If True
A2:M6Expression=SUM(SIGN(MMULT(--(ABS(A2-$A$2:$M$6)<=$O$2),TRANSPOSE(COLUMN($A$2:$M$6)^0))))=SUM(SIGN(MMULT(--($A$2:$M$6>0),TRANSPOSE(COLUMN($A$2:$M$6)^0))))textNO
 
Upvote 0
I don't understand what you are saying.
B2 is highlighted because every row has a number between 74 to 78 inclusive.
 
Upvote 0
I don't understand what you are saying.
B2 is highlighted because every row has a number between 74 to 78 inclusive.
Oh, Ok.

But 77 in Cell D4, 74 in E5 and 77 in A6 are still not being highlighted by conditional formatting.

Could you kindly check why this is happening?
 
Upvote 0
D4 is not highlighted, because it does not meet the conditions
 
Upvote 0
D4 is not highlighted, because it does not meet the conditions
Hi Fluff,

Thanks for your prompt reply on a Sunday morning.
Seems I probably did not give my requirements correctly. Sorry for not be clear.

The requirement was that:

1. All the values in row 2 are the reference values. Therefore row 2 is the Reference row.
- Row 2 in this case and 76 being the reference value.
2. All other rows are the Checking rows.
- Rows 3,4,5,6 are the checking rows
3. Any value (in the checking rows) that falls within +2 or -2 of the values in the reference row should be highlighted.
- Therefore 75 in row 2, 77 in row 3, 74 in row 5 and 77 in row 6 should be highlighted by the conditional formatting formula.
4. Reference Value in the first row, which is common (i.e., +2 or -2 ) across all the checking rows in the reference row should also be highlighted.
- Therefore 76 in row 1 should also be highlighted.

Therefore, 76 in row 1, 75 in row 2, 77 in row 3, 74 in row 5 and 77 in row 6 should be highlighted by the conditional formatting formula. (It seems only values less than 76 are highlighted not more than 76).

Also, I noticed that 77 in rows 4 and 6 are highlighted properly if I delete all the values OR make everything zero in row 5. (This is working correctly as per my original stated request.
 
Upvote 0
Unfortunately I do not know how to do that, hopefully someone else will be able to help.
 
Upvote 0
Unfortunately I do not know how to do that, hopefully someone else will be able to help.
ok. will seek help elsewhere.

Also, could you kindly elaborate why you felt that 77 in D4 did not meet the condition? I am intrigued.

In case you could elaborate, perhaps I might work on an alternative solution.

Thanks for all your efforts.
 
Upvote 0
Because there is nothing in the row below that is within 2 of 77
ok. will seek help elsewhere.
If you ask this question on any other sites, please don't forget to post a link to it here.
 
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,184
Members
453,020
Latest member
Mohamed Magdi Tawfiq Emam

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