Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
I hope that I am posting this in the correct area. If not, please let me know
so I don't make the same mistake twice. Just want to post something that I came up with with the help of several members of the community here. I needed a way to apply more than 3 conditional formats to a range of cells and base those formatting changes on the cells contents. This is the code that I am using to solve this problem. Perhaps something similar will help someone else in a similar situation. Private Sub Worksheet_change(ByVal Target As Range) If Target.Cells.Count 1 Then Exit Sub If Intersect(Target, Me.Range("E5:N77")) Is Nothing _ Then Exit Sub On Error GoTo CleanUp Application.EnableEvents = False With Target Select Case .Value Case "Lunch": .Font.ColorIndex = 0 .Interior.ColorIndex = 6 Case "Off": .Font.ColorIndex = 1 .Interior.ColorIndex = 0 Case "Vac": .Font.ColorIndex = 2 .Interior.ColorIndex = 5 Case "Call Off": .Font.ColorIndex = 1 .Interior.ColorIndex = 45 Case "Holiday": .Font.ColorIndex = 0 .Interior.ColorIndex = 44 Case "Meeting": .Font.ColorIndex = 2 .Interior.ColorIndex = 54 Case "Project": .Font.ColorIndex = 2 .Interior.ColorIndex = 10 Case "Training": .Font.ColorIndex = 2 .Interior.ColorIndex = 48 Case "12-9": .Font.ColorIndex = 1 .Interior.ColorIndex = 0 Case "9-6": .Font.ColorIndex = 1 .Interior.ColorIndex = 0 End Select End With CleanUp: Application.EnableEvents = True End Sub What this will do is in a specific range of cells in a worksheet, change the cell color, and font color according to pre-determined text that is placed in the cell. Example: If the word "Lunch" is entered in a cell within the range E5 to V77, that cell would be colored bright yellow and the font would be colored black. I would like to thank Bob, Tom, Patrick and any others that I might have missed for their invaluable input on my dilemna. I hope that this may help some others out there with similar needs. Thanks! |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Issue with conditional formatting | Excel Discussion (Misc queries) | |||
Conditional Formatting Issue | Excel Discussion (Misc queries) | |||
Conditional Formatting Issue | Excel Discussion (Misc queries) | |||
conditional formatting issue | Excel Worksheet Functions | |||
Conditional Formatting Issue | Excel Programming |