Conditional formatting rule not stopping

288enzo

Well-known Member
Joined
Feb 8, 2009
Messages
721
Office Version
  1. 2016
Platform
  1. Windows
I have two arrays, one includes the word "complete" and the other "incomplete". when the rules are ran, incomplete is being formatted the same as complete. The VBA specifically says "xlEqual", but when I look at the rules under Conditional Formatting they show as "Cell Value end with ___", and the Stop if True is ticked. So, the way it's laid out in the rules are sort of working correctly, they just aren't stopping nor how I intended it to run. How can I change my rules so that after the "Complete" rule has ran it'll stop?

VBA Code:
Sub formatting()
    myArray = Array("Complete", "Up to Date", "Yes")
    For y = LBound(myArray) To UBound(myArray)
        With Range(Cells(2, 13), Cells(2, 13).End(xlDown)).Offset(, 1).resize(, 6)
            .FormatConditions.Add Type:=xlTextString, String:=myArray(y), TextOperator:=xlEqual
            With .FormatConditions(.FormatConditions.Count)
                .Interior.Color = RGB(0, 128, 0)
                .font.Color = RGB(255, 255, 255)
                .StopIfTrue = True
            End With
        End With
    Next
    
    myArray = Array("Test", "Incomplete")
    For y = LBound(myArray) To UBound(myArray)
        With Range(Cells(2, 13), Cells(2, 13).End(xlDown)).Offset(, 3).resize(, 2)
            .FormatConditions.Add Type:=xlTextString, String:=myArray(y), TextOperator:=xlEqual
            With .FormatConditions(.FormatConditions.Count)
                .Interior.Color = RGB(112, 48, 160)
                .font.Color = RGB(255, 255, 255)
                .StopIfTrue = True
            End With
        End With
    Next
End Sub
 

Excel Facts

Can a formula spear through sheets?
Use =SUM(January:December!E7) to sum E7 on all of the sheets from January through December
If you look at the Conditional formatting it is producing, you will find that it is coming up with "Ends with" Complete.
Incomplete "Ends with complete" so it triggers that rule

Maybe try something like this:
VBA Code:
            .FormatConditions.Add Type:=xlCellValue, Formula1:=myArray(y), Operator:=xlEqual
 
Upvote 0

Forum statistics

Threads
1,214,629
Messages
6,120,630
Members
448,973
Latest member
ChristineC

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