LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 130
Default Continued Post - If statement and colors

Thanks Shane and Bob, the code works fine except it does not follow what the
range is saying, the only cell that changes color is O5 and none of the
others react. Below is the final code. Any corrections would be appreciated.

NOTE: I entered additional code to change the font colors as well.


Private Sub Worksheet_Change(ByVal Target As Range)
'-----------------------------------------------------------------
Const WS_RANGE As String = "O5:O43"

On Error Resume Next
If Not Intersect(Target, Me.Range(WS_RANGE)) Is Nothing Then
With Target.Interior
Select Case Target
Case "": .ColorIndex = xlNone
Case 1: .ColorIndex = 3
Case 2: .ColorIndex = 2
Case 3: .ColorIndex = 41
Case 4: .ColorIndex = 6
Case 5: .ColorIndex = 50
Case 6: .ColorIndex = 1
Case 7: .ColorIndex = 46
Case 8: .ColorIndex = 7
Case 9: .ColorIndex = 42
Case 10: .ColorIndex = 13
Case 11: .ColorIndex = 48
Case 12: .ColorIndex = 4
End Select
End With
End If

On Error Resume Next
If Not Intersect(Target, Me.Range(WS_RANGE)) Is Nothing Then
With Target.Font
Select Case Target
Case "": .ColorIndex = xlNone
Case 1: .ColorIndex = 2
Case 2: .ColorIndex = 1
Case 3: .ColorIndex = 2
Case 4: .ColorIndex = 1
Case 5: .ColorIndex = 6
Case 6: .ColorIndex = 6
Case 7: .ColorIndex = 1
Case 8: .ColorIndex = 1
Case 9: .ColorIndex = 1
Case 10: .ColorIndex = 2
Case 11: .ColorIndex = 3
Case 12: .ColorIndex = 1

End Select
End With
End If
ws_exit:
Application.EnableEvents = True
End Sub
 
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
If statement and colors Shu of AZ Excel Discussion (Misc queries) 17 July 1st 08 07:10 PM
If then statement continued! Add to distribution list without opening Excel Discussion (Misc queries) 1 October 20th 06 11:02 PM
Should I generally request "post a poll" when I post a new thread? Joe Miller Excel Discussion (Misc queries) 2 January 7th 06 04:46 PM
Continued Column titles Radish Excel Discussion (Misc queries) 1 July 14th 05 03:41 PM
unhide personal.xls ..... continued excelchallenged Excel Discussion (Misc queries) 0 June 15th 05 07:17 PM


All times are GMT +1. The time now is 11:20 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"