QuadExcel.com

VBA Macros for Conditional Formatting

VBA Macros for Conditional Formatting
VBA Macros for Conditional Formatting

VBA Macro for Conditional Formatting

Private Sub Worksheet_Change (ByVal Target As Range)

Set MyPlage = Range(“C3:I11,C13:I34”)

For Each Cell in MyPlage

If Cell.Value Like “A*” Then

Cell.Interior.ColorIndex = 38

ElseIf Cell.Value Like “B*” Then

Cell.Interior.ColorIndex = 35

ElseIf Cell.Value Like “C*” Then

Cell.Interior.ColorIndex = 34

ElseIf Cell.Value Like “D*” Then

Cell.Interior.ColorIndex = 40

Else

Cell.Interior.ColorIndex = xlNone

End If

        Next
End Sub

This will help you format each cell in a range specified. You can more ElseIf conditions and more color combinations as required.

Exit mobile version