Multiple FormatConditions(1).Interior not working properly

ivill

New Member
Joined
Oct 3, 2021
Messages
37
Office Version
  1. 2019
Platform
  1. Windows
Hi, how do i solve this issue? with multiple conditions, i modified the line With .FormatConditions(1).Interior to With .FormatConditions(2).Interior or (3) (4)... ...etc, but it's not working properly at all...
Could someone advise me? thanks!
VBA Code:
Sub Condition()
Dim rng1 As Range, rng2 As Range, rng3 As Range, rng4 As Range, rng5 As Range, rng6 As Range, rng7 As Range
Sheets("SHEET1").Cells.FormatConditions.Delete

Set rng1 = ThisWorkbook.Worksheets("SHEET1").Range("A3:Z6000")
With rng1
.FormatConditions.Add Type:=xlExpression, Formula1:="=COUNTIFS($A$3:$A3, $A3)=1"
With .FormatConditions(1).Interior
.PatternColorIndex = xlAutomatic
.Color = RGB(183, 225, 205)
.TintAndShade = 0
End With
End With

Set rng2 = ThisWorkbook.Worksheets("SHEET1").Range("F3:G6000")
With rng2
.FormatConditions.Add Type:=xlExpression, Formula1:="=not(isblank(F3:G6000))"
With .FormatConditions(2).Interior
.PatternColorIndex = xlAutomatic
.Color = RGB(252, 232, 178)
.TintAndShade = 0
End With
End With

Set rng3 = ThisWorkbook.Worksheets("SHEET1").Range("N3:O6000")
With rng3
.FormatConditions.Add Type:=xlExpression, Formula1:="=not(isblank(N3:O6000))"
With .FormatConditions(1).Interior
.PatternColorIndex = xlAutomatic
.Color = RGB(221, 235, 247)
.TintAndShade = 0
End With
End With

Set rng4 = ThisWorkbook.Worksheets("SHEET1").Range("P3:Q6000")
With rng4
.FormatConditions.Add Type:=xlExpression, Formula1:="=not(isblank(P3:Q6000))"
With .FormatConditions(2).Interior
.PatternColorIndex = xlAutomatic
.Color = RGB(211, 165, 178)
.TintAndShade = 0
End With
End With

Set rng5 = ThisWorkbook.Worksheets("SHEET1").Range("H3:I6000")
With rng5
.FormatConditions.Add Type:=xlExpression, Formula1:="=not(isblank(H3:I6000))"
With .FormatConditions(1).Interior
.PatternColorIndex = xlAutomatic
.Color = RGB(109, 158, 235)
.TintAndShade = 0
End With
End With

Set rng6 = ThisWorkbook.Worksheets("SHEET1").Range("C3:E6000")
With rng6
.FormatConditions.Add Type:=xlExpression, Formula1:="=not(isblank(C3:E6000))"
With .FormatConditions(1).Font
.Color = RGB(11, 128, 67)
.TintAndShade = 0
End With
End With

Set rng7 = ThisWorkbook.Worksheets("SHEET1").Range("J3:K6000")
With rng7
.FormatConditions.Add Type:=xlExpression, Formula1:="=not(isblank(J3:K6000))"
With .FormatConditions(1).Font
.Color = RGB(197, 57, 41)
.TintAndShade = 0
End With
End With

End Sub
 

Excel Facts

Using Function Arguments with nested formulas
If writing INDEX in Func. Arguments, type MATCH(. Use the mouse to click inside MATCH in the formula bar. Dialog switches to MATCH.
Try it like
VBA Code:
With .FormatConditions(.FormatConditions.Count).Interior
 
Upvote 0
Solution
I dunno how, but it works like a charm, thx boss
 
Upvote 0
You're welcome & thanks for the feedback.
 
Upvote 0

Forum statistics

Threads
1,214,819
Messages
6,121,749
Members
449,050
Latest member
excelknuckles

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