LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 50
Default Solution for conditional formatting issue

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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Issue with conditional formatting The Rook[_2_] Excel Discussion (Misc queries) 2 June 2nd 10 05:36 PM
Conditional Formatting Issue Robert Excel Discussion (Misc queries) 8 September 1st 08 11:05 PM
Conditional Formatting Issue afsoares Excel Discussion (Misc queries) 3 June 30th 06 01:36 PM
conditional formatting issue QUESTION-MARK Excel Worksheet Functions 3 April 20th 06 01:04 AM
Conditional Formatting Issue John Baker Excel Programming 2 July 4th 04 12:52 PM


All times are GMT +1. The time now is 09:44 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"