Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.scripting.vbscript,microsoft.public.excel.programming
|
|||
|
|||
![]()
Hello all.
I've got a VBScript that creates an XLS file. In it I want to implement conditional formatting; where if a cell value in Column C is greater than 50000, then that cell font will be changed to bold and red. Recording a macro gave me this: Sub Bold_Red() Columns("C:C").Select Selection.FormatConditions.Delete Selection.FormatConditions.Add Type:=xlCellValue, Operator:=xlGreater, _ Formula1:="50000" With Selection.FormatConditions(1).Font .Bold = True .ColorIndex = 3 .Italic = False End With End Sub Then, after adding these Constants: Const xlCellValue = 1 Const xlGreater = 5 I transposed the above macro into the following code: '~~ Insert Bold and Red Font for any value '~~ greater than 50000 in Column C objExcel.Range("C:C").Select objExcel.Selection.FormatConditions.Delete objExcel.Selection.FormatConditions.Add xlCellValue, xlGreater, "50000" With objExcel.Selection.FormatConditions(1).Font .Bold = True .ColorIndex = 3 'Red .Italic = False End With The code works fine except for one problem. Some of the cells in Column C contain text, not a number, and the text is getting changed to the Bold and Red font. I want the font to change only for cells that contain a number, not text. How do I exclude the text cells from the conditional formatting? Any suggestions would be greatly appreciated. Thanks! - Dave |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Conditional formatting using text and exceptions | Excel Worksheet Functions | |||
Excel: How to make conditional formatting work with hyperlinks | Excel Discussion (Misc queries) | |||
Need to make a "range" in conditional formatting. | Excel Discussion (Misc queries) | |||
How to Make a Cell Flash in Excel using conditional formatting | Excel Discussion (Misc queries) | |||
Can I make a cell flash in conditional formatting? | Excel Programming |