IFfunction来检查同一范围内的多个条件

我想突出显示细胞取决于细胞的价值。

如果它是一个单一的值,我可以用IF函数来完成。 我试图确定它的值是“9900”还是“9100”。摄像头请给我解释一下我的错误在哪里(我知道这是代码的第一行)

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 

如果你想突出显示它,如果该值既不是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 

这是我发现的,

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