我在A列中有以下值的列表,如下所示。我要突出显示没有字符串“是”,“否”和“ N / A”的单元格
Moderate
High
Yes - no structural changes
High
Moderate
Yes
Moderate
N/A
High
No
Nos
我尝试了下面的VBA,但是它也没有突出显示“是-没有结构性变化”和“否”之类的值。
Dim a As Range
For Each a In Range(Range("a1"), Range("a" & Rows.Count).End(xlUp))
If Not (a.Value Like "**Yes**" Or a.Value Like "**No**" Or a.Value Like "**N/A**") Then
a.Interior.ColorIndex = 3
End If
Next a
答案 0 :(得分:0)
只需添加条件格式设置规则即可。
with worksheets("sheet1")
with .range(.cells(1, "A"), .cells(.rows.count, "A").end(xlup))
with .formatconditions.add(type:=xlexpression, _
formula1:="=OR(COUNTIF(A1, ""*yes*""), COUNTIF(A1, ""*no*""), COUNTIF(A1, ""*n/a*""))")
.interior.color = vbred
end with
end with
end with
您自己的代码需要使用带有Like的通配符。
If Not (a.Value Like "*Yes*" Or a.Value Like "*No*" Or a.Value Like "*N/A*") Then