【发布时间】:2021-03-08 13:24:53
【问题描述】:
如果列 E 包含例如 1ST,我想通过 VBA 应用条件格式,那么我想对它旁边的 28 个单元格使用多个条件格式规则。
此刻我使用
Sub SetFormulasFormat()
With ActiveSheet
For Each cl In Application.Intersect(.Columns("E"), .UsedRange)
' found upper row of the data in table
If UCase(cl.Text) = "1ST" Then
cl.Resize(, 1).FormatConditions.Add Type:=xlCellValue, Operator:=xlLess, _
Formula1:="=1"
cl.Resize(, 1).FormatConditions(1).Interior.Color = vbRed
cl.Resize(, 2).FormatConditions.Add Type:=xlCellValue, Operator:=xlLess, _
Formula1:="=3"
cl.Resize(, 2).FormatConditions(2).Interior.Color = vbRed
End If
Next cl
End With
结束子
但我没有应用第二条规则。
我的excel示例
有人可以帮我吗?
【问题讨论】:
-
您的代码创建了一个 CF 规则,它只检查单元格值是否为 1(或 3)。您是否尝试根据列 E = 1ST 中的值为整行着色?
-
如果文本是 1ST,我需要它来检查 F 列是否小于 1,然后它需要检查 G 和 H 列是否小于 3,如果你需要检查其他列的其他数字明白我的意思了吗。它只需要突出显示它需要检查的 cel
标签: excel vba search conditional-formatting