Conditional Formatting Based on Average of Previous Cells

SDowse

Board Regular
Joined
Sep 23, 2009
Messages
120
Hi,

I have a simple spreadsheet, let's say 2 rows, 10 columns.

I am trying to do conditional formatting that highlights a cell where the value of that cell is 0, but the average of the previous cells in the row is greater than 0.

For example:
12345678910
1234500000
12345678910

In the 2nd row above, I want the cells that a zero to be highlighted, because the previous cells are not 0. I have managed to do this on a single cell, where I use average of the previous columns, but I cannot work out how to expand the range in conditional formatting, so that as I drag the formatting across, the first cell is "anchored" but the range picks up all the subsequent columns - i.e. the range should be from the first column up to the column immediately before the cell being formatted (but the conditional formatting across the entire row - if that makes sense).

The reason I need this sort of dynamic range is because through time the columns may be updated and numbers other than zero calculated.

Hoping someone can help - thank you in advance.
 
Ok, so in a row, like the example given above, I want conditional formatting to highlight a cell in red where:
1. The date in the first row (which will be the first of each month) is greater than EOMONTH(TODAY(),-1)
2. The value in each cell does not equal 0
3. The values in all of the columns to left of each column are not 0 - I used AVERAGE to do this, I just couldn't work out how to "anchor" the first column and then have the range expand across the row - so H would be C:G, I would be C:H, J would be C:I etc...

Hopefully that is clear?
 
Upvote 0

Excel Facts

Add Bullets to Range
Select range. Press Ctrl+1. On Number tab, choose Custom. Type Alt+7 then space then @ sign (using 7 on numeric keypad)
Ok, how about
Fluff.xlsm
CDEFGHIJKLMNOPQRSTUVWXYZAAABAC
2Jan-22Feb-22Mar-22Apr-22May-22Jun-22Jul-22Aug-22Sep-22Oct-22Nov-22Dec-22Jan-23Feb-23Mar-23Apr-23May-23Jun-23Jul-23Aug-23Sep-23Oct-23Nov-23Dec-23Jan-24Feb-24Mar-24
18£0£0£62£1,292£1,513£5,170£2,632£6,696£6,856£7,924£0£0£0£0£0£0£0£0£0£0£0£0£0£0£0£0£0
19£0£0£1,401£4,000£0£0£0£0£0£0£0£0£0£0£0£0£0£0£0£0£0£0£0£0£0£0£0
20£0£0£6£0-£628-£785£0£0£0£0£0£0£0£0£0£0£0£0£0£0£0£0£0£0£0£0£0
21£0£0£0£180£634£3,453£1,701£1,902£1,584£1,644£2,802£8,787£14,185£18,263£19,659£17,272£15,554£0£0£0£0£0£0£0£0£0£0
Main
Cells with Conditional Formatting
CellConditionCell FormatStop If True
D18:AC21Expression=AND(D18=0,D$2>EOMONTH(TODAY(),-1),AVERAGE($C18:C18)<>0)textNO
 
Upvote 0
Many thanks - I'll give that a try. Will a simple paste format across all the cells work and adjust the $C18:C18 across all the columns?
 
Upvote 0
Just select D18 to the last cell it needs to work on & then apply the rule.
 
Upvote 0
Excellent, that seems to have worked - many thanks. Some oddities in my data made it look a bit weird at first, but all seems to be working. Thanks for your help.
 
Upvote 0
You're welcome & thanks for the feedback.
 
Upvote 0

Forum statistics

Threads
1,216,028
Messages
6,128,400
Members
449,448
Latest member
Andrew Slatter

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