Cell fill based on value of cell in row before

lee2121

New Member
Joined
Mar 14, 2017
Messages
41
Hello Everyone.

I have an excel file where i need the current cell to be filled with let's say a light red colour if the value entered into this cell is the same or less than the value in the cell above it.

For example

Cell A2 = 100 and Cell A1 = 110 then cell A2 should fill red and repeat for all other cells in the row.

I think a VBA solution may be best for this. I can do this in conditional formatting but i can't set up conditional formatting rules for each cell

The cells i need this to work on are Rows 2, 4, 6, 8 and 10

cell fill.png
 

Excel Facts

Which lookup functions find a value equal or greater than the lookup value?
MATCH uses -1 to find larger value (lookup table must be sorted ZA). XLOOKUP uses 1 to find values greater and does not need to be sorted.
Hello,

With conditional formatting you can just select let's say the second cell of a column, go to Conditional Formatting > New Rule > Use a Formula > And write:

Excel Formula:
= B1>B2
(or whatever cells such as B2 is the current one, and B1 the one above)

TAKE CARE TO REMOVE THE DOLLARS (and setup a highlight style).

Then just Format paint / paste to the whole row. Cells where the one above them is bigger will be highlighted according to the style you defined.

You need to remove the dollars to make the conditional formatting not absolute.
 
Upvote 0
How about
Fluff.xlsm
B
1
2312.775
3304.702
4292.655
5270.97
6258.811
7259.311
8251.107
9245.12
10240.007
11237.017
12236.736
13232.957
14
15
16
Sheet6
Cells with Conditional Formatting
CellConditionCell FormatStop If True
B2:B16Expression=AND(MOD(ROW(B2),2)=1,B2<=B1,B2<>"")textNO
 
Upvote 0
Hello,

With conditional formatting you can just select let's say the second cell of a column, go to Conditional Formatting > New Rule > Use a Formula > And write:

Excel Formula:
= B1>B2
(or whatever cells such as B2 is the current one, and B1 the one above)

TAKE CARE TO REMOVE THE DOLLARS (and setup a highlight style).

Then just Format paint / paste to the whole row. Cells where the one above them is bigger will be highlighted according to the style you defined.

You need to remove the dollars to make the conditional formatting not absolute.
Thank you this works
 
Upvote 0
How about
Fluff.xlsm
B
1
2312.775
3304.702
4292.655
5270.97
6258.811
7259.311
8251.107
9245.12
10240.007
11237.017
12236.736
13232.957
14
15
16
Sheet6
Cells with Conditional Formatting
CellConditionCell FormatStop If True
B2:B16Expression=AND(MOD(ROW(B2),2)=1,B2<=B1,B2<>"")textNO
sorry but i do not know where i should enter your code?
 
Upvote 0
Select the range you want to format, then in CF select use a formula & paste in the formula I showed.
 
Upvote 0
Hello,

With conditional formatting you can just select let's say the second cell of a column, go to Conditional Formatting > New Rule > Use a Formula > And write:

Excel Formula:
= B1>B2
(or whatever cells such as B2 is the current one, and B1 the one above)

TAKE CARE TO REMOVE THE DOLLARS (and setup a highlight style).

Then just Format paint / paste to the whole row. Cells where the one above them is bigger will be highlighted according to the style you defined.

You need to remove the dollars to make the conditional formatting not absolute.
when i use the format painter it then highlights all cells and changes the formula to below
 

Attachments

  • cell fill 2.png
    cell fill 2.png
    15.5 KB · Views: 4
Upvote 0
Yes it is normal. It can be a bit confusing because you see a unique formula, but it applies it for each cell taking the local coordinates since we took away the $.

So for instance in B30 it checks =B29>B30 and not =B2>B1.
 
Upvote 0
Yes it is normal. It can be a bit confusing because you see a unique formula, but it applies it for each cell taking the local coordinates since we took away the $.

So for instance in B30 it checks =B29>B30 and not =B2>B1.
sorry but it only seems to be calculating the second cell in the row. If i change the value in the second cell so that it is not filled all other cells will also not be filled
 

Attachments

  • cell fill 4.png
    cell fill 4.png
    22.3 KB · Views: 3
Upvote 0
Well maybe you should try Fluff's proposition then.
You probably misunderstood some of the instructions I gave you. I checked it again and no problem. Make sure you are referring to the correct cells in the formula.
 
Upvote 0

Forum statistics

Threads
1,224,810
Messages
6,181,079
Members
453,021
Latest member
Justyna P

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