VBScript to set conditional formatting for cells

R

Rod Cohen

Hello,
I want to accomplish two key objectives. The first and foremost is:

Have a VB Script conditionally format cells based on their contents.
I would like to have the script do:
If ŒY¹ or Œy¹ entered into the cells the fill color becomes Green
If ŒN¹ or Œn¹ is entered into the cells the fill color becomes Red
If ŒV¹ or Œv¹ or ŒVacation¹ is entered into the cell the fill color becomes
light green
If ŒNFT¹ or Œnft¹ is entered into the cell the fill color becomes another
color
This would work for the entire workbook

I may even want to change or bold the font. I have looked at a number of
scripts but have not had ay luck.

The next script I would like to add is that if ay of the information above
is entered into the cell, the case is changed to uppercase.

Any and all help is appreciated.

Thank You,
Rod
 
K

kg_singapore

Hi Rod,

Try this code for color changing.

private sub ..
range("A1:D10").Select
Selection.FormatConditions.Delete
Selection.FormatConditions.Add Type:=xlCellValue, Operator:=xlEqual, _
Formula1:="=""R"""
Selection.FormatConditions(1).Interior.ColorIndex = 3
Selection.FormatConditions.Add Type:=xlCellValue, Operator:=xlEqual, _
Formula1:="=""G"""
Selection.FormatConditions(2).Interior.ColorIndex = 50
Selection.FormatConditions.Add Type:=xlCellValue, Operator:=xlEqual, _
Formula1:="=""B"""
Selection.FormatConditions(3).Interior.ColorIndex = 5
end sub

regards
KarthiGanesh
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top