我试图突出细胞取决于细胞价值。
如果它是单个值,我可以使用IF函数。我试图确定该值是否为" 9900"或"" 9100"。 Cam有人请解释我哪里弄错了? (我知道这是代码的第一行)
If Range("E" & i).Value <> "9900" Or "9100" Then
Range("A" & i & ":" & "L" & i).Select
With Selection.Interior
.Pattern = xlSolid
.PatternColorIndex = xlAutomatic
.ThemeColor = xlThemeColorAccent2
.TintAndShade = 0.399975585192419
.PatternTintAndShade = 0
End With
With Selection.Font
.Color = -16711681
.TintAndShade = 0
End With
End If
Next i
答案 0 :(得分:1)
如果要突出显示它,如果该值既不是9900也不是9100,那么它是
If Range("E" & i).Value <> "9900" And Range("E" & i).Value <> "9100" Then
另一种方式是
If Range("E" & i).Value = "9900" Or Range("E" & i).Value = "9100" Then
答案 1 :(得分:0)
这是我发现的,
If Range("E" & i).Value <> "9900" Then
If Range("E" & i).Value <> "9100" Then
Range("A" & i & ":" & "L" & i).Select
With Selection.Interior
.Pattern = xlSolid
.PatternColorIndex = xlAutomatic
.ThemeColor = xlThemeColorAccent2
.TintAndShade = 0.399975585192419
.PatternTintAndShade = 0
End With
With Selection.Font
.Color = -16711681
.TintAndShade = 0
End With
End If
End If
答案 2 :(得分:-1)
last_row = Application.Workbooks(file_name).Worksheets("ms").Range("a65536").End(xlUp).Row
Range("A" & last_row & ":" & "L" & last_row).Select
With Selection.Interior
.Pattern = xlSolid
.PatternColorIndex = xlAutomatic
.ThemeColor = xlThemeColorAccent2
.TintAndShade = 0.399975585192419
.PatternTintAndShade = 0
End With
With Selection.Font
.Color = -16711681
.TintAndShade = 0
End With
If Range("E" & i).Value <> "9900" Or "9100" Then
Range("A" & i & ":" & "L" & i).Select
With Selection.Interior
.Pattern = xlNone
.TintAndShade = 0
.PatternTintAndShade = 0
End With
End If
Next i