+ Reply to Thread
Results 1 to 6 of 6

If statement to test font color

  1. #1
    Gary
    Guest

    If statement to test font color

    I have seen this question in reverse on the forum. Usually the question is
    to change the font color when criteria is met.

    I need to test the font color in order to determine value. I can do it in
    code with a for..next loop but I was wondering if it could be done in an if
    statement?

    Example: If(fontcolor (A2) = "Red", then "Next Day", "Standard")

    What would be the syntax?

    Thanks for the help.

  2. #2
    Bernard Liengme
    Guest

    Re: If statement to test font color

    Chip has lots on colours; www.cpearson.com
    best wishes
    --
    Bernard V Liengme
    www.stfx.ca/people/bliengme
    remove caps from email

    "Gary" <Gary@discussions.microsoft.com> wrote in message
    news:3E724D9B-0A0F-4FCB-BDF2-FFF7CCCF62A5@microsoft.com...
    >I have seen this question in reverse on the forum. Usually the question is
    > to change the font color when criteria is met.
    >
    > I need to test the font color in order to determine value. I can do it in
    > code with a for..next loop but I was wondering if it could be done in an
    > if
    > statement?
    >
    > Example: If(fontcolor (A2) = "Red", then "Next Day", "Standard")
    >
    > What would be the syntax?
    >
    > Thanks for the help.




  3. #3
    PDUK1
    Guest

    RE: If statement to test font color

    Try this:

    Sub FontColor()
    MsgBox "The Font Color Index is " & ActiveCell.Font.ColorIndex
    End Sub

    If Cell.Font.ColorIndex = 3 Then xxxx

    Peter





    "Gary" wrote:

    > I have seen this question in reverse on the forum. Usually the question is
    > to change the font color when criteria is met.
    >
    > I need to test the font color in order to determine value. I can do it in
    > code with a for..next loop but I was wondering if it could be done in an if
    > statement?
    >
    > Example: If(fontcolor (A2) = "Red", then "Next Day", "Standard")
    >
    > What would be the syntax?
    >
    > Thanks for the help.


  4. #4
    Gary
    Guest

    RE: If statement to test font color

    Peter,

    Thanks for the quick response.

    I may not have been clear. I was looking for a way to enter that same idea
    into a cell. Is that possible?

    "PDUK1" wrote:

    > Try this:
    >
    > Sub FontColor()
    > MsgBox "The Font Color Index is " & ActiveCell.Font.ColorIndex
    > End Sub
    >
    > If Cell.Font.ColorIndex = 3 Then xxxx
    >
    > Peter
    >
    >
    >
    >
    >
    > "Gary" wrote:
    >
    > > I have seen this question in reverse on the forum. Usually the question is
    > > to change the font color when criteria is met.
    > >
    > > I need to test the font color in order to determine value. I can do it in
    > > code with a for..next loop but I was wondering if it could be done in an if
    > > statement?
    > >
    > > Example: If(fontcolor (A2) = "Red", then "Next Day", "Standard")
    > >
    > > What would be the syntax?
    > >
    > > Thanks for the help.


  5. #5
    Chip Pearson
    Guest

    Re: If statement to test font color

    There is no way within a formula to determine a cell's color,
    either background or foreground. You need a VBA function. See the
    "Returning The ColorIndex Of A Cell" on
    www.cpearson.com/excel/colors.htm .


    --
    Cordially,
    Chip Pearson
    Microsoft MVP - Excel
    Pearson Software Consulting, LLC
    www.cpearson.com


    "Gary" <Gary@discussions.microsoft.com> wrote in message
    news:3E724D9B-0A0F-4FCB-BDF2-FFF7CCCF62A5@microsoft.com...
    >I have seen this question in reverse on the forum. Usually the
    >question is
    > to change the font color when criteria is met.
    >
    > I need to test the font color in order to determine value. I
    > can do it in
    > code with a for..next loop but I was wondering if it could be
    > done in an if
    > statement?
    >
    > Example: If(fontcolor (A2) = "Red", then "Next Day",
    > "Standard")
    >
    > What would be the syntax?
    >
    > Thanks for the help.




  6. #6
    Gary
    Guest

    Re: If statement to test font color

    Chip,

    Thanks for the confirmation. I thought that might be the answer but was
    hoping.

    "Chip Pearson" wrote:

    > There is no way within a formula to determine a cell's color,
    > either background or foreground. You need a VBA function. See the
    > "Returning The ColorIndex Of A Cell" on
    > www.cpearson.com/excel/colors.htm .
    >
    >
    > --
    > Cordially,
    > Chip Pearson
    > Microsoft MVP - Excel
    > Pearson Software Consulting, LLC
    > www.cpearson.com
    >
    >
    > "Gary" <Gary@discussions.microsoft.com> wrote in message
    > news:3E724D9B-0A0F-4FCB-BDF2-FFF7CCCF62A5@microsoft.com...
    > >I have seen this question in reverse on the forum. Usually the
    > >question is
    > > to change the font color when criteria is met.
    > >
    > > I need to test the font color in order to determine value. I
    > > can do it in
    > > code with a for..next loop but I was wondering if it could be
    > > done in an if
    > > statement?
    > >
    > > Example: If(fontcolor (A2) = "Red", then "Next Day",
    > > "Standard")
    > >
    > > What would be the syntax?
    > >
    > > Thanks for the help.

    >
    >
    >


+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1