Conditional formatting abs Val > 1 <2 with color scale

brenmacd

New Member
Joined
Apr 10, 2024
Messages
3
Office Version
  1. 2016
Platform
  1. Windows
Hello

I am trying to color my cell based on the absolute value of the contents of that cell such that: the cell is green if less than one, gradually turns from green to red between 1 and 2, and red if greater than 2. Thanks!
 

Excel Facts

Control Word Wrap
Press Alt+Enter to move to a new row in a cell. Lets you control where the words wrap.
Is this the sort of thing you're after?
1712778443365.png
 
Upvote 0
Yes but I have to deal with negative numbers so need to consider absolute values. Thank you for your reply!
 
Upvote 0
Attempt #1:

Book2 (version 1).xlsb
AB
1
2
3
4-3
5-2.7
6-2.4
7-2.1
8-1.8
9-1.5
10-1.2
11-0.9
12-0.6
13-0.3
140
150.3
160.6
170.9
181.2
191.5
201.8
212.1
22
Sheet3
Cell Formulas
RangeFormula
B4:B21B4=SEQUENCE(18,,-3,0.3)
Dynamic array formulas.
Cells with Conditional Formatting
CellConditionCell FormatStop If True
B4:B21Expression=ABS(B4)>2textYES
B4:B21Expression=ABS(B4)<1textYES
B4:B21Other TypeColor scaleNO


I used 3 rules to accomplish this, and yes, the range -2 to -1 is not correct. I have 2 rules for ABS()<1 and ABS()>2, and one rule for a color scale between 1 and 2. I thought I could add another color scale rule between -2 and -1, but no such luck. The color scale rule prevents any other rules below it from working. So I added a few more rules, and while not ideal, kinda works:

Attempt #2:

Book2 (version 1).xlsb
AB
1
2
3
4-3
5-2.7
6-2.4
7-2.1
8-1.8
9-1.5
10-1.2
11-0.9
12-0.6
13-0.3
140
150.3
160.6
170.9
181.2
191.5
201.8
212.1
22
Sheet5
Cells with Conditional Formatting
CellConditionCell FormatStop If True
B4:B21Expression=ABS(B4)>2textYES
B4:B21Expression=ABS(B4)<1textYES
B4:B21Expression=B4<-1.7textYES
B4:B21Expression=B4<-1.3textYES
B4:B21Expression=B4<-1textYES
B4:B21Other TypeColor scaleNO


The color transition is not as smooth. You could probably get something a bit better with VBA.
 
Upvote 0

Forum statistics

Threads
1,215,196
Messages
6,123,578
Members
449,108
Latest member
rache47

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