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.

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *

eighteen + 10 =

This site uses Akismet to reduce spam. Learn how your comment data is processed.