Conditional Format Font Colour

JeannetteE

Board Regular
Joined
May 19, 2016
Messages
53
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
 

Excel Facts

Excel Wisdom
Using a mouse in Excel is the work equivalent of wearing a lanyard when you first get to college
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
 
Upvote 0
Solution
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 :laugh:
 
Upvote 0
You're welcome & thanks for the feedback
 
Upvote 0

Forum statistics

Threads
1,224,820
Messages
6,181,160
Members
453,021
Latest member
Justyna P

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top