Results 1 to 4 of 4

Thread: Conditional Format Font Colour
Thanks Thanks: 0 Likes Likes: 0

  1. #1
    New Member
    Join Date
    May 2016
    Posts
    47
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default Conditional Format Font Colour

    Hi,

    I have a Range of Data that has a normal Font Color of Black, however there is a Conditional Format in place to Change the Font to Red if that Value is not in a specific list. This all works fine but I want to be able to check if any of the values are in Red Text before a macro runs and if there are to Exit the code. My problem is that the code I have only seems to recognize the Formatted Font and not the Conditional Font. I have only added the 2 TestColor lines to test the Values but they all come back with the same values, TestColorFC = 3 and TestColorF = -4105. Any help as always is greatly appreciated.

    Code:
    Sub TestFontColor()
        LastRow = Range("tblSMServices[Service]").End(xlDown).Row
            For i = 4 To LastRow
    
                    TestColorFC = Sheets("Services").Range("C" & i).FormatConditions(1).Font.ColorIndex
                    TestColorF = Sheets("Services").Range("C" & i).Font.ColorIndex
    
    
            If Range("C" & i).FormatConditions(1).Font.ColorIndex = 3 Then
                MsgBox "Test"
                GoTo Finish
            End If
            Next
    Finish:
    End Sub

  2. #2
    MrExcel MVP
    Moderator
    Fluff's Avatar
    Join Date
    Jun 2014
    Location
    Chippenham
    Posts
    28,190
    Post Thanks / Like
    Mentioned
    470 Post(s)
    Tagged
    47 Thread(s)

    Default Re: Conditional Format Font Colour

    How about
    Code:
    Sub TestFontColor()
       LastRow = Range("tblSMServices[Service]").End(xlDown).Row
       For i = 4 To LastRow
          If Range("C" & i).DisplayFormat.Font.ColorIndex = 3 Then
             MsgBox "Test"
             Exit Sub
          End If
       Next
    End Sub
    - Posting Data try one of these tools
    - Posting guidelines, forum rules and terms of use
    - Read the FAQs

    Running Office 365 on Win 10

  3. #3
    New Member
    Join Date
    May 2016
    Posts
    47
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default Re: Conditional Format Font Colour

    Quote Originally Posted by Fluff View Post
    How about
    Code:
    Sub TestFontColor()
       LastRow = Range("tblSMServices[Service]").End(xlDown).Row
       For i = 4 To LastRow
          If Range("C" & i).DisplayFormat.Font.ColorIndex = 3 Then
             MsgBox "Test"
             Exit Sub
          End If
       Next
    End Sub
    OMG so easy! Thank you so much, I can't believe I didn't get it! Well I can lol

  4. #4
    MrExcel MVP
    Moderator
    Fluff's Avatar
    Join Date
    Jun 2014
    Location
    Chippenham
    Posts
    28,190
    Post Thanks / Like
    Mentioned
    470 Post(s)
    Tagged
    47 Thread(s)

    Default Re: Conditional Format Font Colour

    You're welcome & thanks for the feedback
    - Posting Data try one of these tools
    - Posting guidelines, forum rules and terms of use
    - Read the FAQs

    Running Office 365 on Win 10

Some videos you may like

User Tag List

Tags for this Thread

Like this thread? Share it with others

Like this thread? Share it with others

Posting Permissions

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