View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.programming
Tom Ogilvy Tom Ogilvy is offline
external usenet poster
 
Posts: 27,285
Default skipping text formats

are the values constants?

Sub ChangeCellBasedonValue()
Dim limit As Integer
limit = Range("k1").Value
For Each c In ActiveSheet.Range("e:e").SpecialCells(xlConstants, xlNumbers)
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


This should speed up your macro as well, since specialcells restricts itself
to the used range.
--
Regards,
Tom Ogilvy

"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