Reputation: 125
I'm trying to use the .style
function in this formatting, but vba doesn't want to use it. Am I just using the .style
wrong or do I need to use a different method to color the cells?
'Conditional Formatting
.FormatConditions.Delete
.FormatConditions.Add xlErrorsCondition, Formula1:= _
"=IF(" & Cells(SelectedGroup, AreaSelected(2)).Offset(2, 1) & "=""Not Used"",TRUE, _
FALSE)"
.FormatConditions(1).Style = "Bad"
.FormatConditions.Add xlErrorsCondition, Formula1:= _
"=IF(" & Cells(SelectedGroup, AreaSelected(2)).Offset(2, 1) & "=""Used"",TRUE,FALSE)"
.FormatConditions(1).Style = "Good"
Upvotes: 0
Views: 1579
Reputation: 1584
Style is a property of the Range object. In order to use it, you need to end your With statement and apply the style to the Range itself.
https://msdn.microsoft.com/en-us/vba/excel-vba/articles/range-style-property-excel
Upvotes: 1