在以下情况下在Excel中进行条件格式化

如果“B”列的相应单元格中的值包含“Valid”,“Validate”或“Evaluate”等内容,则我想突出显示其内容不包含文本的Excel单元格值“Y”。

如果列“B”中的相应单元格的值为“N”,则列“A”不能包含“validation”,“validation”和“评估”等单词。 所以只需要突出显示这些差异,如果它存在。

列“A”:按Enter键,validation这一点,这…

“B”栏:是

这是一个很快的例子。 但是,如果列B不能为空,则可以将第二个公式缩短。 看看这是否适合…

例

编辑

这里是VBA示例的要求。 您将需要将代码保存到当前工作表(例如:Sheet1)…

 Option Explicit Private Sub Worksheet_Change(ByVal Target As Range) Dim str As String Dim lCol As Long Dim oCell As Object Dim oCellFormat As Object lCol = Target.Column If lCol = 1 Or lCol = 2 Then Set oCell = Cells(Target.Row, 1) Else GoTo mExit End If str = UCase(oCell.Value) Set oCellFormat = Cells(oCell.Row, 1) If (str = "VERIFY" Or str = "VALIDATE" Or str = "EVALUATE") Then If UCase(Cells(oCell.Row, 2).Value) = "N" Then oCellFormat.Interior.ColorIndex = 3 'red ElseIf UCase(Cells(oCell.Row, 2).Value) = "Y" Then oCellFormat.Interior.ColorIndex = 4 'green Else oCellFormat.Interior.ColorIndex = 2 'white End If Else oCellFormat.Interior.ColorIndex = 2 'white End If GoTo mExit Exit Sub mExit: Set oCell = Nothing 'free resources Set oCellFormat = Nothing End Sub