Thread: Use CASE?
View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
Risky Dave Risky Dave is offline
external usenet poster
 
Posts: 161
Default Use CASE?

Hi,

I have a piece of code that adds validation to specific cells in a row.

' Format effectiveness rating
Set rEffectiveness = Range("e" & lLineCount & ",H" & lLineCount & ",k" &
lLineneCount & ",n" & lLineCount & ",q" & lLineCount)
With rEffectiveness.Validation
.Delete
.Add Type:=xlValidateList, AlertStyle:=xlValidAlertStop,
Operator:=xlBetween, Formula1:="Adequate, Improvement Required, Weak"
.IgnoreBlank = True
.InCellDropdown = True
.InputTitle = ""
.ErrorTitle = ""
.InputMessage = ""
.ErrorMessage = ""
.ShowInput = True
.ShowError = True
End With

For each valid value entered by the user, I want to conditionally format
the cell so that "Adequate" is Green, "Improvement Required" is Yellow and
"Weak" is Red (all font colours to be black).

This feels like a place to use a CASE statement, but I am not sure of the
syntax within VB, so can anyone suggest an approach?

TIA

Dave