![]() |
|
|||||||
|
|
|
Thread Tools | Display Modes |
|
|
|
#1
|
|||
|
|||
|
Why does this work when I have only a single FormatConditions(1) statement:
Code:
' Single FormatConditions(1) statement
' Why does this work
Sub CF_NO_with()
' Row 5
' Column1
Range(Cells(303, 5), Cells(308, 24)).FormatConditions.Delete
Range(Cells(303, 5), Cells(308, 24)).FormatConditions.Add Type:=xlExpression, Formula1:="=MOD(column(),2)=0"
Range(Cells(303, 5), Cells(308, 24)).FormatConditions(1).Interior.ColorIndex = 15
End Sub
Code:
' Multiple FormatConditions(1) statement
' Why does this NOT work ((if you have multiple FormatConditions(1) statements?))
Sub CF_NO_with()
' Row 5
' Column1
Range(Cells(303, 5), Cells(308, 24)).FormatConditions.Delete
Range(Cells(303, 5), Cells(308, 24)).FormatConditions.Add Type:=xlExpression, Formula1:="=MOD(column(),2)=0"
Range(Cells(303, 5), Cells(308, 24)).FormatConditions(1).Interior.ColorIndex = 15
' Works up to here. Next line is an error why?
Range(Cells(303, 5), Cells(308, 24)).FormatConditions(1).PatternColorIndex = 15
Range(Cells(303, 5), Cells(308, 24)).FormatConditions(1).Pattern = xlGray75
End Sub
Code:
' This works ((Control)
Sub CF_with()
Range(Cells(303, 5), Cells(308, 24)).FormatConditions.Delete
Range(Cells(303, 5), Cells(308, 24)).Select
With Selection
.FormatConditions.Delete
.FormatConditions.Add Type:=xlExpression, Formula1:="=MOD(column(),2)=0"
With .FormatConditions(1).Interior
.ColorIndex = 15
.PatternColorIndex = 15
.Pattern = xlGray75
End With
End With
End Sub
|
|
#2
|
|||
|
|||
|
Quote:
Code:
Range(Cells(303, 5), Cells(308, 24)).FormatConditions(1).interior.PatternColorIndex = 15 Range(Cells(303, 5), Cells(308, 24)).FormatConditions(1).interior.Pattern = xlGray75 |
|
#3
|
|||
|
|||
|
Doh!!!
Thank you much appreciated.... |
|
#4
|
|||
|
|||
|
You're welcome !
|
|
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
Conditional Formatting Individual Rows in a range
|
Phil H | Excel | 3 | 11-05-2018 12:09 PM |
Conditional Formatting - Duplicates - Apply to specified range
|
music_al | Excel Programming | 1 | 01-25-2017 05:34 AM |
| Conditional Formatting a Range | Phil H | Excel | 3 | 02-17-2016 08:33 AM |
| VBA Conditional Formatting Error (Subscript out of Range)) | tinfanide | Excel Programming | 1 | 05-15-2015 08:12 AM |
| Conditional Formatting/If Statement with Dates | AndrewEnos | Excel | 2 | 07-22-2014 07:34 AM |