|
[广告] Excel易用宝 - 提升Excel的操作效率 · Excel / WPS表格插件 ★ 免费下载 ★ ★ 使用帮助★
我知道的就只能利用宏了,宏我不怎么会,只会录制一个宏,然后修改里面的数据,然后运行。
-------
下面是代码
Sub Macro1()
'
' Macro1 Macro
' 宏由 Administrator 录制,时间: 2022/06/10
'
'
Range("B4:C999").Select
Selection.FormatConditions.Add Type:=xlExpression, Operator:=-1, Formula1:="=$B4<>$C4", Formula2:=""
Selection.FormatConditions(Selection.FormatConditions.Count).SetFirstPriority
Selection.FormatConditions(1).Interior.Pattern = xlPatternSolid
Selection.FormatConditions(1).Interior.PatternColorIndex = -4105
Selection.FormatConditions(1).Interior.PatternTintAndShade = 0
Selection.FormatConditions(1).Interior.Color = 65535
Selection.FormatConditions(1).Interior.TintAndShade = 0
Selection.FormatConditions(1).StopIfTrue = False
Range("E4:F999").Select
Selection.FormatConditions.Add Type:=xlExpression, Operator:=-1, Formula1:="=$E4<>$F4", Formula2:=""
Selection.FormatConditions(Selection.FormatConditions.Count).SetFirstPriority
Selection.FormatConditions(1).Interior.Pattern = xlPatternSolid
Selection.FormatConditions(1).Interior.PatternColorIndex = -4105
Selection.FormatConditions(1).Interior.PatternTintAndShade = 0
Selection.FormatConditions(1).Interior.Color = 65535
Selection.FormatConditions(1).Interior.TintAndShade = 0
Selection.FormatConditions(1).StopIfTrue = False
Range("H4:I999").Select
Selection.FormatConditions.Add Type:=xlExpression, Operator:=-1, Formula1:="=$H4<>$I4", Formula2:=""
Selection.FormatConditions(Selection.FormatConditions.Count).SetFirstPriority
Selection.FormatConditions(1).Interior.Pattern = xlPatternSolid
Selection.FormatConditions(1).Interior.PatternColorIndex = -4105
Selection.FormatConditions(1).Interior.PatternTintAndShade = 0
Selection.FormatConditions(1).Interior.Color = 65535
Selection.FormatConditions(1).Interior.TintAndShade = 0
Selection.FormatConditions(1).StopIfTrue = False
End Sub
|
|