VBA Conditional formatting

Excel Facts

Pivot Table Drill Down
Double-click any number in a pivot table to create a new report showing all detail rows that make up that number
Click conditional formatting
Click use a formula to determine which cells to format
enter =COUNTIF(R:R,"*cnf*") as your formula
Apply which ever formatting you need
Click ok
In the applies to box enter =$R:$R
click apply.

now if any cell in column R contains cnf it will highlight the entire column R.

Sorry about no pictures I am on my phone.
 
Upvote 0
Click conditional formatting
Click use a formula to determine which cells to format
enter =COUNTIF(R:R,"*cnf*") as your formula
Apply which ever formatting you need
Click ok
In the applies to box enter =$R:$R
click apply.

now if any cell in column R contains cnf it will highlight the entire column R.

Sorry about no pictures I am on my phone.

Thank you . I know how to do this manually, I`m looking for VBA script

Thanks,
 
Upvote 0
Thank you . I know how to do this manually, I`m looking for VBA script

Thanks,

If you know how to do it manually does the macro recorder not give you the code :confused:
 
Upvote 0
Try this

Code:
Sub HIGHLIGHT_cnf()
    With Application
         .Calculation = xlCalculationManual
         .ScreenUpdating = False
    Const TEST_COLUMN As String = "R"
    Dim cell As Range
   ssheetname = ActiveSheet.Name
     
    With Worksheets(ssheetname)
        Range("R:R").Interior.ColorIndex = 0
        For Each cell In Range("R:R")
            If Not IsError(cell.Value) Then
                If cell.Value = "cnf" Then
                    cell.EntireColumn.Interior.ColorIndex = 3
            End If
        End If
       Next
    End With
    .Calculation = xlCalculationAutomatic
        .ScreenUpdating = True
    End With
End Sub

How are you going to make it run? Manually or do you want to check for cell changes in column R.
 
Last edited:
Upvote 0
Without the loop:

Code:
Sub CondF()
Dim rng As Range, f$
f = "=countif(r:r,""*cnf*"")"
f = "=CONT.SE(R:R;""*cnf*"")"                                   ' choose a formula
Set rng = [r:r]
With rng
    .FormatConditions.Add xlExpression, , f
    .FormatConditions(rng.FormatConditions.count).SetFirstPriority
    .FormatConditions(1).Interior.Color = 45990
    .FormatConditions(1).StopIfTrue = 0
End With
End Sub
 
Upvote 0

Forum statistics

Threads
1,214,646
Messages
6,120,717
Members
448,985
Latest member
chocbudda

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