![]() |
VBScript to set conditional formatting for cells
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 |
VBScript to set conditional formatting for cells
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 "Rod Cohen" wrote: 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 |
All times are GMT +1. The time now is 05:34 PM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com