Conditional formatting

James__S

Active Member
Joined
Jan 26, 2014
Messages
332
Hi

I am using the following rules in Conditional formatting
format Only Cells that Contain
1. Cell Value Greater than =206 will turn RED
2. Cell Value Less than or equal to =205 will turn GREEN

now if i have nothing in the range the Cell is still RED....how do i have the cell White if there is no value in the cell

Thanks
 

Excel Facts

Excel Wisdom
Using a mouse in Excel is the work equivalent of wearing a lanyard when you first get to college
Hi,

I'm getting the other way around, staying GREEN, anyway try changing "Less than or equal to" 205, if there won't be negative numbers or zeros, between >=1 and <=205
 
Upvote 0
You're welcome, the reason I believe is that Excel assigns a 0 value to a blank cell for logic comparison, therefore, blank cell <=205 returns TRUE.
 
Last edited:
Upvote 0
Good day All

Try
Code:
Sub AdConditions()


Dim Rng As Range, CondRng As Range
    Dim CondClr As Variant
    Dim Adrs As String
    Dim C As Long
    
   Set CondRng = Range("A1:H10") 'Conditions range
   'Set CondRng = Range("A1:A20") 'Conditions range for some in Column (A)
   For Each Rng In CondRng
   With Rng
   Adrs = Rng.Address
   CondFrml = Split("=AND(" & Adrs & "<>""""," & Adrs & "<=205);=AND(" & Adrs & "<>""""," & Adrs & ">=206)", ";") 'Conditions Formula
   CondClr = Split("38400;255", ";") ' color
    .FormatConditions.Delete
    For C = LBound(CondFrml) To UBound(CondFrml)
            .FormatConditions.Add Type:=xlExpression, Formula1:=CondFrml(C) 'Conditions Formula
            .FormatConditions(.FormatConditions.Count).SetFirstPriority
            With .FormatConditions(1).Interior
                .PatternColorIndex = xlAutomatic
                .Color = CondClr(C) ' color
            End With
        .FormatConditions(1).StopIfTrue = False
    Next
    End With
    Next
    
End Sub
 
Upvote 0

Forum statistics

Threads
1,215,639
Messages
6,125,968
Members
449,276
Latest member
surendra75

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