View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Ken Wright Ken Wright is offline
external usenet poster
 
Posts: 634
Default skipping text formats

One way:-

Sub ChangeCellBasedonValue()
Dim limit As Integer
limit = Range("k1").Value
For Each C In ActiveSheet.Range("e:e").Cells
If C.Value limit And C.Value < 9.999999999E+99 Then
With C.Font
.Bold = False
.Italic = False
.ColorIndex = 3
End With
With C.Interior
.ColorIndex = 14
End With
End If
Next C
MsgBox "All done!"
End Sub

but this would be done so much better by using Conditional formatting which would be
dynamic and change as your data changed without the need for any macros. Also, you could
definitely choose a better colour combination. White font usually works best with a dark
background.

--
Regards
Ken....................... Microsoft MVP - Excel
Sys Spec - Win XP Pro / XL2K & XLXP

----------------------------------------------------------------------------
Attitude - A little thing that makes a BIG difference
----------------------------------------------------------------------------



"Jay" wrote in message
...
Hi:

The following program goes through a column of data and
highlights vlues over a certain constant. The only
problem is that it also highlights the cells with text
also? Can anybody show me how to highlight numbers only?

Thanks in advance for your help!

Sub ChangeCellBasedonValue()
Dim limit As Integer
limit = Range("k1").Value
For Each c In ActiveSheet.Range("e:e").Cells
If c.Value limit Then
With c.Font
.Bold = False
.Italic = False
.ColorIndex = 3
End With
With c.Interior
.ColorIndex = 14
End With
End If
Next c
MsgBox "All done!"
End Sub



---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.528 / Virus Database: 324 - Release Date: 16/10/2003