View Single Post
  #10   Report Post  
Posted to microsoft.public.excel.programming
Tom Ogilvy Tom Ogilvy is offline
external usenet poster
 
Posts: 27,285
Default Comditional Formatting Problem

Right click on the sheet tab and select view code. Put in code like this.

Private Sub Worksheet_Calculate()
With Range("F9:G9")
If IsError(.Item(1, 1).Value) Then
.Font.ColorIndex = xlAutomatic
Else
If .Item(1, 1).Value 1 Then
.Font.ColorIndex = 3
Else
.Font.ColorIndex = 4
End If
End If
End With
End Sub

--
Regards,
Tom Ogilvy

"Ed P" wrote in message
...
Tom,
With your suggestion I have discoverd that the problem is not laying

within
my code but rather the execution of the code.
I need this macro to run anytime the cell reaches 100.01%.
Do you have any suggestions for this.
We are taking a step in the right direction.
I appreciate your help on this.
Thank You
Ed

"Tom Ogilvy" wrote:

Sub Red()
Range("F9:G9").Select
If ActiveCell.Value 1 Then
ActiveCell.Font.ColorIndex = 3
End If
End Sub

worked fine for me with F9:G9 merged.

cell was formatted as percentage and was displaying 101%

from the immediate window you can see the actual value stored in the

cell:

? ActiveCell.Value
1.01

I guess you need to see what value is actually stored in the cell.

Sub Red()
Range("F9:G9").Select
MsgBox "Value: " & ActiveCell.Value & _
" Display: " & ActiveCell.Text
If ActiveCell.Value 1 Then
ActiveCell.Font.ColorIndex = 3
End If
End Sub

--
Regards,
Tom Ogilvy



"Ed P" wrote in message
...
Tom,
I apprecaite your help.
I have entered the Code as you instructed, but it still is not working
correctly.
I had originally chose 2 cells because those cells are merged. I am

not
sure
if this is the problem or not.
Do you have any other suggestions?
Thanks again for your help.
Ed

"Tom Ogilvy" wrote:

Sub Red()
Range("F9").Select
If ActiveCell.Value 1 Then
ActiveCell.Font.ColorIndex = 3
End If
End Sub

would be what i would try if your cells contains percentages.

Also, if you are only working with the activecell, why select more

than
one
cell.

--
Regards,
Tom Ogilvy


"Ed P" wrote in message
...
Can someone help me determine what is wrong with the following

code.
I am needing to change the color of the text in a cell to red if

the
cell
is
100%.
My code I have currently is follows.

Sub Red()
Range("F9:G9").Select
If ActiveCell.Value 100 Then
ActiveCell.Font.ColorIndex = 3
End If
End Sub

I appreciate any help you can give me.
If I am taking the wrong approach please advise.
Thank You
Ed