VBA conditional order issue

tezza

Active Member
Joined
Sep 10, 2006
Messages
375
Office Version
  1. 2016
  2. 2010
Platform
  1. Windows
  2. Web
Hi all,

I've got a list of conditional formats that need to go in a specific order (see below), no matter how I do it I can't get them right.

Please can someone help?

Office 365

Excel Formula:
Private Sub condformat()
'
' Macro6 Macro
'

'
    Worksheets("RC_Call_Logs").Select
    
    For Each TmpSht In ThisWorkbook.Sheets
    TmpSht.Cells.FormatConditions.Delete
    Next
    
    Columns("I:I").Select
    Selection.FormatConditions.Add Type:=xlExpression, Formula1:= _
        "=$M1=""No Start Time"""
    'Selection.FormatConditions(Selection.FormatConditions.Count).SetFirstPriority
    With Selection.FormatConditions(1).Interior
        .ThemeColor = xlThemeColorAccent6
        .TintAndShade = 0.599963377788629
    End With
    Selection.FormatConditions(1).StopIfTrue = False
    
   
    Columns("J:J").Select
    Selection.FormatConditions.Add Type:=xlExpression, Formula1:="=I2>J2"
    Selection.FormatConditions(Selection.FormatConditions.Count).SetFirstPriority
    With Selection.FormatConditions(1).Interior
        .PatternColorIndex = xlAutomatic
        .ThemeColor = xlThemeColorAccent5
        .TintAndShade = 0.799981688894314
    End With
    Selection.FormatConditions(1).StopIfTrue = False

    
    Columns("K:K").Select
    Selection.FormatConditions.Add Type:=xlExpression, Formula1:= _
        "=COUNTA($A1:$M1)=1"
    'Selection.FormatConditions(Selection.FormatConditions.Count).SetFirstPriority
    Selection.FormatConditions(1).StopIfTrue = True
            
    Columns("K:K").Select
    Selection.FormatConditions.Add Type:=xlExpression, Formula1:= _
        "=$H1-$K1>TIME(0,15,0)"
    'Selection.FormatConditions(Selection.FormatConditions.Count).SetFirstPriority
    With Selection.FormatConditions(1).Interior
        .PatternColorIndex = xlAutomatic
        .ThemeColor = xlThemeColorAccent4
        .TintAndShade = 0.399945066682943
    End With
    Selection.FormatConditions(1).StopIfTrue = False
    

End Sub
 

Excel Facts

Create a chart in one keystroke
Select the data and press Alt+F1 to insert a default chart. You can change the default chart to any chart type
no matter how I do it I can't get them right.
It would probably help if you could describe what "right" looks like.
Could you share your file via Dropbox, Google Drive or similar file sharing platform (you can easily disguise any sensitive data) and describe in words exactly how you want the order of the conditional formatting to work?
 
Upvote 0
It would probably help if you could describe what "right" looks like.
Could you share your file via Dropbox, Google Drive or similar file sharing platform (you can easily disguise any sensitive data) and describe in words exactly how you want the order of the conditional formatting to work?
Here's a visual of the original post and the order I need it to be:

1688199513998.png
 
Upvote 0
Thank you for that. If you're unable to share your actual file, could you at least provide a copy of your sheet via the XL2BB - Excel Range to BBCodeXL2BB - Excel Range to BBCode - without which it would be impossible to test whether any suggested code will give you what you want.
As you see, the 'Stop if True' format is at the bottom, but I need it in third position.

All it does is remove the orange box in Col K just above each grey line but for work purpose it helps alot.

_RCLogs_tester.xlsm
ABCDEFGHIJKLMNOP
1Day of WeekDate of CallStaffClientsChargeable Rate SheetCall Start TimeCall End TimeCall DurationReal StartReal EndDurationCCFNotes1158
2Monday22/05/2023EDBloggs, JoeCustomer11:0014:0003:0010:5813:5202:54123abcNo Start Time 02:54 
3Wednesday24/05/2023EDBloggs, JoeCustomer11:0017:0006:0010:5616:5606:00123abcNo Start Time 06:00 
4Friday26/05/2023SCBloggs, JoeCustomer10:3013:3003:0010:3113:2402:53123abcNo Start Time 02:53 
5Monday29/05/2023EDBloggs, JoeCustomer11:0014:0003:0010:5313:5202:59123abcNo Start Time 02:59 
6Wednesday31/05/2023EDBloggs, JoeCustomer11:0017:0006:0010:5216:5306:01123abcNo Start Time 06:01 
7Friday02/06/2023SCBloggs, JoeCustomer10:3013:3003:0010:2913:2903:00123abcNo Start Time 03:00 
8Monday05/06/2023EDBloggs, JoeCustomer11:0014:0003:0010:5913:5402:55123abcNo Start Time 02:55 
9Wednesday07/06/2023EDBloggs, JoeCustomer11:0017:0006:0011:0717:0505:58123abcNo Start Time 05:58 
10Friday09/06/2023SCBloggs, JoeCustomer10:3013:3003:0010:2513:2603:01123abcNo Start Time 03:01 
11Tuesday13/06/2023JGBloggs, JoeCustomer10:0013:0003:0010:0113:0103:00123abcNo Start Time 03:00 
12Wednesday14/06/2023EDBloggs, JoeCustomer11:0017:0006:0010:5316:4605:53123abcNo Start Time 05:53 
13Friday16/06/2023SCBloggs, JoeCustomer10:3013:3003:0010:3713:3402:57123abcNo Start Time 02:57 
1448:00P00:00 
15 00:00 
16 00:00 
Call_Logs
Cell Formulas
RangeFormula
O1O1=COUNTIF(N2:N10000,"P")
P1P1=COUNTA(UNIQUE(D2:D10000))-1
N2:N16N2=IF(AND(COUNT(A2:M2)=1,H2<>""),"P","")
O2:O16O2=J2-I2
P2:P16P2=IF(OR(O2=K2,MROUND(O2,"00:01")=MROUND(K2,"00:01")),"","Check")
H14H14=SUM(H2:H13)
Cells with Conditional Formatting
CellConditionCell FormatStop If True
J:JExpression=I2>J2textNO
I:IExpression=$M1="No Start Time"textNO
K:KExpression=COUNTA($A1:$M1)=1textNO
K:KExpression=$H1-$K1>TIME(0,15,0)textYES
 
Upvote 0
I've figured it out using an AND function in the conditional format:

VBA Code:
=AND(COUNTA(A1:M1)>1,$H1-$K1>TIME(0,15,0))

I just had to learn about how to put formulas in the conditional format properly.
 
Upvote 0
I've figured it out using an AND function in the conditional format:

VBA Code:
=AND(COUNTA(A1:M1)>1,$H1-$K1>TIME(0,15,0))

I just had to learn about how to put formulas in the conditional format properly.
Well done 👍 ✔️
 
Upvote 0

Forum statistics

Threads
1,215,091
Messages
6,123,062
Members
449,089
Latest member
ikke

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