Excel-vba:条件格式:单元格样式

时间:2022-06-29 20:24:19

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?

我正在尝试在此格式中使用.style函数,但vba不想使用它。我只是使用.style错误还是我需要使用不同的方法为细胞着色?

'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"

1 个解决方案

#1


0  

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.

Style是Range对象的属性。要使用它,您需要结束With语句并将样式应用于Range本身。

https://msdn.microsoft.com/en-us/vba/excel-vba/articles/range-style-property-excel

https://msdn.microsoft.com/en-us/vba/excel-vba/articles/range-style-property-excel

#1


0  

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.

Style是Range对象的属性。要使用它,您需要结束With语句并将样式应用于Range本身。

https://msdn.microsoft.com/en-us/vba/excel-vba/articles/range-style-property-excel

https://msdn.microsoft.com/en-us/vba/excel-vba/articles/range-style-property-excel