Conditional Formating

Chandresh

Board Regular
Joined
Jul 21, 2009
Messages
146
HI All,

I want to do the following things with the help of conditional formatting.

1) if cell is blank - no colour
2) if cell value is greater than 5% cell should be blue
3) if cell value is less than -5% cell should be blue

I am using below code however I am not getting the results , could you please help.

Sub SpecCheckred()
Sheets("Summary").Select
Dim iRow As Range
Set iRow = Range("b4:BH50000")
For Each cell In iRow
If cell.Value <> "" And cell.Value > 0.05 And cell.Value < -0.05 Then
cell.Interior.Color = RGB(22, 255, 255)
End If
Next
End Sub



Thanks
Chan
 

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.
HI All,

I want to do the following things with the help of conditional formatting.

1) if cell is blank - no colour
2) if cell value is greater than 5% cell should be blue
3) if cell value is less than -5% cell should be blue

I am using below code however I am not getting the results , could you please help.

Sub SpecCheckred()
Sheets("Summary").Select
Dim iRow As Range
Set iRow = Range("b4:BH50000")
For Each cell In iRow
If cell.Value <> "" And cell.Value > 0.05 And cell.Value < -0.05 Then
cell.Interior.Color = RGB(22, 255, 255)
End If
Next
End Sub



Thanks
Chan
It is impossible for the red part to ever be true. A value cannot be both greater than 0.05 And less than -0.05 at the same time. Therefore, the blue code will never be executed.
Try
Rich (BB code):
If cell.Value <> "" And (cell.Value > 0.05 Or cell.Value < -0.05) Then
 
Last edited:
Upvote 0
hi,

if I use below code my entire range becomes blue

If cell.Value <> "" And (cell.Value > 0.05 Or cell.Value < -0.05) Then

thanks
Chan
 
Upvote 0
hi,

if I use below code my entire range becomes blue

If cell.Value <> "" And (cell.Value > 0.05 Or cell.Value < -0.05) Then

thanks
Chan
Not for me. Here is my sample sheet after running the code.


Book1
BCD
40.08110.09450.0408
50.04330.59
60.0647
70.00260.06410.0884
8260.02580.0015
90.10.0340.0245
100.08090.02320.0623
Summary



Are you sure that your data is numerical, not text?
 
Upvote 0

Forum statistics

Threads
1,223,214
Messages
6,170,771
Members
452,353
Latest member
strainu

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