我正在编写一个宏,它是一个大项目的一部分。最后一点是,如果W列满足条件,则对V列中的单元格应用条件格式。
我得到
运行时错误5:无效的过程调用或参数错误。
Sub ComConFormGreen()
'
' ComConForGreen Macro
'
'
Columns("W:W").Select
Selection.FormatConditions.Add Type:=xlCellValue, Operator:=xlEqual, _
Formula1:="=""Each"""
Selection.FormatConditions(Selection.FormatConditions.Count).SetFirstPriority
With Selection.FormatConditions(1).Font
.Color = -16752384
.TintAndShade = 0
End With
With Selection.FormatConditions(1).Interior
.PatternColorIndex = xlAutomatic
.Color = 13561798
.TintAndShade = 0
End With
Selection.FormatConditions(1).StopIfTrue = False
Columns("V:V").Select
Selection.FormatConditions.Add Type:=xlCellValue, Operator:=xlEqual, _
Formula1:="=""$W1=""Each"""""
Selection.FormatConditions(Selection.FormatConditions.Count).SetFirstPriority
With Selection.FormatConditions(1).Font
.Color = -16752384
.TintAndShade = 0
End With
With Selection.FormatConditions(1).Interior
.PatternColorIndex = xlAutomatic
.Color = 13561798
.TintAndShade = 0
End With
Selection.FormatConditions(1).StopIfTrue = False
End Sub
问题似乎出现在以下行中:
Selection.FormatConditions.Add Type:=xlCellValue, Operator:=xlEqual, _
Formula1:="=""$W1=""Each"""""
1条答案
按热度按时间ddhy6vgd1#
条件规则在xlCellValue中查找值,但您尝试解析公式,因此应改用xlExpression。