LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.scripting.vbscript,microsoft.public.excel.programming
external usenet poster
 
Posts: 6
Default Excel conditional formatting - how to make exceptions?

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
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
Conditional formatting using text and exceptions Nic Daniels Excel Worksheet Functions 4 July 28th 09 12:34 PM
Excel: How to make conditional formatting work with hyperlinks ChadBellan Excel Discussion (Misc queries) 3 May 25th 07 02:18 PM
Need to make a "range" in conditional formatting. DocMartigan Excel Discussion (Misc queries) 3 October 7th 05 04:19 AM
How to Make a Cell Flash in Excel using conditional formatting aboehnen Excel Discussion (Misc queries) 1 April 23rd 05 01:53 AM
Can I make a cell flash in conditional formatting? Ghostboy Excel Programming 1 February 24th 05 01:46 PM


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