简体   繁体   English

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

[英]Excel-vba: Conditional Formatting: Cell Style

I'm trying to use the .style function in this formatting, but vba doesn't want to use it. 我正在尝试以这种格式使用.style函数,但是vba不想使用它。 Am I just using the .style wrong or do I need to use a different method to color the cells? 我只是在错误地使用.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"

Style is a property of the Range object. 样式是Range对象的属性。 In order to use it, you need to end your With statement and apply the style to the Range itself. 为了使用它,您需要结束With语句并将样式应用于Range本身。

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM