Conditional Formatting

Frank Harrison

New Member
Joined
Feb 8, 2023
Messages
12
Office Version
  1. 365
  2. 2021
Platform
  1. Windows
  2. Mobile
I am looking to use conditional formatting to highlight a cell when a one in five rows condition is exceeded.

Order KeyVS-455
A04532X
A01323
A01022
A01331
A06877X Thid cell should highligrt red because there is an "X" Four rows above
A01003
A01922
A02403
A02740
A04565X
A01394
A01246
A07754
A01271
A09886X
 

Excel Facts

Return population for a City
If you have a list of cities in A2:A100, use Data, Geography. Then =A2.Population and copy down.
You should be able to use a COUNTIF to count how many "X"s there are in the 4 rows above, and if it is more than 0, i.e. the Conditional Formatting formula would start in B6 and look like:
Excel Formula:
=COUNTIF(B2:B5,"X")>0
 
Upvote 0
Every time an "X" occurs I need it to evaluate the four cell above and below to make sure no othes rows contain an "X"
 
Upvote 0
OK, looks you conditions changed, as you now want to check above AN D below, instead of just below.

What row/column does your data actually start in?
 
Upvote 0
Sample file attached I think the rows above would nohave to be considered because they would be covered.
 

Attachments

  • Bom.jpg
    Bom.jpg
    59.1 KB · Views: 5
Upvote 0
What row/column does your data actually start in?
You did not answer my question, and your image does not show row or column headers, so I cannot see what ranges you are working with.
 
Upvote 0
Sorry, I was out of town for a few days and just getting back now.

Your image does not seem to match you last description, in which you said:

Every time an "X" occurs I need it to evaluate the four cell above and below to make sure no othes rows contain an "X"

Your image suggest it is only looking one way, and not both, or else lines 9 and 23 would also be highlighted.

If your image is accurate (and your last description is not), then if you select B6 to the end of your range, you can then use this Conditional Formatting formula:
Excel Formula:
=AND(B6="X",COUNTIF(B2:B5,"X")>0)

You would need to use slightly adjusted formula for cells B3:B5, i.e.

for cell B3:
Excel Formula:
=AND(B3="X",B2="X")>0)

for cell B4:
Excel Formula:
=AND(B4="X",COUNTIF(B2:B3,"X")>0)

for cell B5:
Excel Formula:
=AND(B5="X",COUNTIF(B2:B4,"X")>0)
 
Upvote 0

Forum statistics

Threads
1,216,185
Messages
6,129,388
Members
449,506
Latest member
nomvula

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