PC Review


Reply
Thread Tools Rate Thread

cell color condition

 
 
Can-Ann
Guest
Posts: n/a
 
      21st Jan 2008
Using Office 2007
I want to run a specific routine if a cell foreground is red.
Can anyone show me what the formula would be.
Thanks in Advance
 
Reply With Quote
 
 
 
 
SteveM
Guest
Posts: n/a
 
      22nd Jan 2008
On Jan 21, 2:53 pm, Can-Ann <Can...@discussions.microsoft.com> wrote:
> Using Office 2007
> I want to run a specific routine if a cell foreground is red.
> Can anyone show me what the formula would be.
> Thanks in Advance


You have to examine the ColorIndex property so do something like:

Sub CheckColor()
Dim cell as Range

For Each cell in Range("Whatever")
If cell.Interior.ColorIndex = "the Index Number" Then
do something
End If
Next

End Sub

You can find the index numbers for the color palette using help on the
ColorIndex property.

Although it may be easier just evaluating the cell using the same
conditions that colored it red in the first place

SteveM
 
Reply With Quote
 
JLGWhiz
Guest
Posts: n/a
 
      23rd Jan 2008
I am going to assume that you mean the interior color of the cell, since it
does not have a foreground property.

If the cell was colored using the conditional format method:

Sub findColorRed()
If ActiveCell.FormatConditions(1).Interior.ColorIndex = 3 Then
'Put your code here
End If
End Sub

If the cell was colored using regular format method:

Sub findColorRed()
If ActiveCell.Interior.ColorIndex = 3 Then
'Put your code here
End If
End Sub

"Can-Ann" wrote:

> Using Office 2007
> I want to run a specific routine if a cell foreground is red.
> Can anyone show me what the formula would be.
> Thanks in Advance

 
Reply With Quote
 
JLGWhiz
Guest
Posts: n/a
 
      23rd Jan 2008
If this is redundant ignore it. I don't see my original postl

There are two condidtions that can color the cell. If it is
colored by conditional format then:

Sub findColorRed()
If ActiveCell.FormatConditions(1).Interior.ColorIndex = 3 Then
' Your code here
End If
End Sub

If it is colored by regular format then:

Sub findColorRed()
If ActiveCell.Interior.ColorIndex = 3 Then
' Your code here
End If
End Sub




"Can-Ann" wrote:

> Using Office 2007
> I want to run a specific routine if a cell foreground is red.
> Can anyone show me what the formula would be.
> Thanks in Advance

 
Reply With Quote
 
Sam Wilson
Guest
Posts: n/a
 
      23rd Jan 2008
If you already have the sub written (Sub MySub() ..... End sub) then the
following sub should do what you want or at least point you in the right
direction.

sub Demo()

If Range("A1").interior.colorindex = 3 then call MySub

End Sub


"Can-Ann" wrote:

> Using Office 2007
> I want to run a specific routine if a cell foreground is red.
> Can anyone show me what the formula would be.
> Thanks in Advance

 
Reply With Quote
 
filo666
Guest
Posts: n/a
 
      23rd Jan 2008
try this:

If ActiveCell.Interior.ColorIndex = 3 Then
MsgBox "the selected cell has red background", vbOKOnly
End If

if it was helpfull please press yes.

greatings from Israel

"Can-Ann" wrote:

> Using Office 2007
> I want to run a specific routine if a cell foreground is red.
> Can anyone show me what the formula would be.
> Thanks in Advance

 
Reply With Quote
 
santaviga
Guest
Posts: n/a
 
      23rd Jan 2008
Try using conditional formatting.

M

"Can-Ann" wrote:

> Using Office 2007
> I want to run a specific routine if a cell foreground is red.
> Can anyone show me what the formula would be.
> Thanks in Advance

 
Reply With Quote
 
Barb Reinhardt
Guest
Posts: n/a
 
      23rd Jan 2008
I used this to figure out the colors on a sheet I set up

Sub test()
Dim r As Range
For Each r In ActiveSheet.UsedRange
Debug.Print r.Address, r.Interior.ColorIndex, r.Font.Color
Next r
End Sub

But you'll have to check for yourself.

I believe what you want is
If ActiveCell.font.color = 255 then

end if

--
HTH,
Barb Reinhardt



"Can-Ann" wrote:

> Using Office 2007
> I want to run a specific routine if a cell foreground is red.
> Can anyone show me what the formula would be.
> Thanks in Advance

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Is there a way to color a cell if it meets specific condition Sekhar Microsoft Excel Misc 6 16th Nov 2008 05:39 PM
counting cell by color and condition =?Utf-8?B?TWFyaw==?= Microsoft Excel Misc 1 22nd Apr 2007 04:56 PM
Change Cell Color On Condition Of Cell =?Utf-8?B?U2Vhbg==?= Microsoft Excel Programming 1 9th May 2006 11:52 PM
I want to fill the cell color based upon the other cell condition =?Utf-8?B?c3Jp?= Microsoft Excel Misc 4 12th Jan 2006 01:47 PM
Using cell color as condition in equation =?Utf-8?B?Sm9objMx?= Microsoft Excel Programming 2 7th Jan 2004 08:49 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 11:06 PM.