#1   Report Post  
Posted to microsoft.public.excel.programming
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
  #2   Report Post  
Posted to microsoft.public.excel.programming
AGP AGP is offline
external usenet poster
 
Posts: 5
Default Use CASE?

Type in SELECT CASE in the macro, highlight the words, and click F1 that
will open up the help.

AGP

"Risky Dave" wrote in message
...
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



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,942
Default Use CASE?

hi
i don't think select case would work here. select case choose one options
from a list. with conditional formating, you want all three. add this to the
end or your code.
Dim r As Range
Set r = Range("I3") 'change to suit
r.FormatConditions.Delete
r.FormatConditions.Add Type:=xlCellValue, Operator:=xlEqual, _
Formula1:="=""Adequate"""
r.FormatConditions(1).Interior.ColorIndex = 4
r.FormatConditions.Add Type:=xlCellValue, Operator:=xlEqual, _
Formula1:="=""needs improvement"""
r.FormatConditions(2).Interior.ColorIndex = 6
r.FormatConditions.Add Type:=xlCellValue, Operator:=xlEqual, _
Formula1:="=""weak"""
r.FormatConditions(3).Interior.ColorIndex = 3

regards
FSt1
"Risky Dave" wrote:

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

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 161
Default Use CASE?

AGP, FSt1

My thanks. Excatly what I needed :-)

Dave

"FSt1" wrote:

hi
i don't think select case would work here. select case choose one options
from a list. with conditional formating, you want all three. add this to the
end or your code.
Dim r As Range
Set r = Range("I3") 'change to suit
r.FormatConditions.Delete
r.FormatConditions.Add Type:=xlCellValue, Operator:=xlEqual, _
Formula1:="=""Adequate"""
r.FormatConditions(1).Interior.ColorIndex = 4
r.FormatConditions.Add Type:=xlCellValue, Operator:=xlEqual, _
Formula1:="=""needs improvement"""
r.FormatConditions(2).Interior.ColorIndex = 6
r.FormatConditions.Add Type:=xlCellValue, Operator:=xlEqual, _
Formula1:="=""weak"""
r.FormatConditions(3).Interior.ColorIndex = 3

regards
FSt1
"Risky Dave" wrote:

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

Reply
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
countif function: how to distinguish case/make case sensitive mvwoolner Excel Worksheet Functions 3 March 18th 09 02:18 PM
change data of entire column from small case to upper case Ann Excel Worksheet Functions 1 August 16th 08 01:06 PM
Changing multiple cell text from lower case to upper case Patti Excel Discussion (Misc queries) 2 January 4th 08 08:35 PM
Change the text from lower case to upper case in an Excel work boo dave01968 Excel Discussion (Misc queries) 2 December 9th 05 09:09 AM
How to use formula auditing to change upper case to Title Case. ScoobeyDoo Excel Worksheet Functions 1 November 19th 04 06:26 PM


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