View Single Post
  #6   Report Post  
Posted to microsoft.public.excel.programming
keiji kounoike keiji kounoike is offline
external usenet poster
 
Posts: 199
Default 3 Conditions for Data Validation for a List


Just move the code changing font color part in the FontColorChange into
your first Worksheet_Change

Private Sub Worksheet_Change(ByVal Target As Range)
On Error GoTo ws_exit:
Application.EnableEvents = False
With Target
If .Column = 8 Then
Select Case .Value
Case "Not Started":
.Interior.ColorIndex = 2 'White
.Font.ColorIndex = 1
Case "Completed":
.Interior.ColorIndex = 5 'Blue
.Font.ColorIndex = 2
Case "Manageable Issues":
.Interior.ColorIndex = 6 'Yellow
.Font.ColorIndex = 1
Case "Significant Issues":
.Interior.ColorIndex = 3 'Red
.Font.ColorIndex = 2
Case "On Track":
.Interior.ColorIndex = 10 ' Green
.Font.ColorIndex = 2
End Select
End If
End With

ws_exit:
Application.EnableEvents = True
End Sub

Keiji

Anders wrote:
drop-down - If you have to define the values a user can input into a
cell, one where they can see what the values they can choose from are, how
would you do it? I've found the easiest for me is a data-validation-allow
list-define range etc. I'm open to other ways if they're better. **Note -
I have people not too comfortable with excel using the sheets to deliver
status updates to me so ease of use is key.

what have I tried. I've gotten something to work since my last post -

1. This code is what I've modified, (found in the MS help docs): it
successfully changes the fill color
Private Sub Worksheet_Change(ByVal Target As Range)

On Error GoTo ws_exit:
Application.EnableEvents = False
With Target
If .Column = 8 Then
Select Case .Value
Case "Not Started": .Interior.ColorIndex = 2 'White
Case "Completed": .Interior.ColorIndex = 5 'Blue
Case "Manageable Issues": .Interior.ColorIndex = 6 'Yellow
Case "Significant Issues": .Interior.ColorIndex = 3 'Red
Case "On Track": .Interior.ColorIndex = 10 ' Green
End Select
End If
End With

ws_exit:
Application.EnableEvents = True
End Sub

3. I need to change the font color as well for readability. So can I add
that to this code or do i need to write a different one? I tried writing a
different one (below, doesn't work)

Private Sub FontColorChange(ByVal Target As Range)

On Error GoTo ws_exit:
Application.EnableEvents = False
With Target
If .Column = 8 Then
Select Case .Value
Case "Not Started": .Font.ColorIndex = 1 ' Black
Case "Completed": .Font.ColorIndex = 2 'White
Case "Manageable Issues": .Font.ColorIndex = 1 'Black
Case "Significant Issues": .Font.ColorIndex = 2 'White
Case "On Track": .Font.ColorIndex = 2 'White
End Select
End If
End With

ws_exit:
Application.EnableEvents = True
End Sub

**What i'm getting with this is the font just is never changing color. If
the code is right, maybe I'm setting it up wrong in the editor - such as
where I'm placing it???

Thanks.