Macro for Conditional Formatting - Only on One Column

Viewed 15

My apologies ahead of time. I have no idea what I am doing. I have this code that I grabbed from random place.

Here's what I'm tying to accomplish. I have a spreadsheet with over 100 tabs (or sheets or whatever).

I want to highlight all cells that are higher than 50%.

The problem I ran into with the code below is that I have some $ values in column A, B and C. So while it does work for the most part, it also picks up $0.50 - $1.50 as well and I don't want that.

Can anyone help me?

Sub AddCF()

Dim w As Worksheet
For Each w In Worksheets
    With w.UsedRange.FormatConditions.Add(Type:=xlCellValue, Operator:=xlBetween, Formula1:="=0.50", Formula2:="1.50")
        .Font.Color =vbWhite
        .Font.Bold = True
        .Interior.Color = vbRed
    End With
Next w

End Sub

1 Answers

even though it's probably not the most performatic way to do it, try this:

Sub AddCF()
Dim w As Worksheet
For Each w In Worksheets
With w.UsedRange.FormatConditions.Add(Type:=xlCellValue, Operator:=xlBetween, Formula1:="=0.50", Formula2:="<1.00")
    .Font.Color = vbWhite
    .Font.Bold = True
    .Interior.Color = vbRed
    
End With

With w.Columns("A:C")
.FormatConditions.Delete
End With
Next w
End Sub
Related