我在宏中进行条件格式化(因为我会不断地将它与其他格式一起应用到新的原始导出中)。
目标:突出显示单元格J(n)中的文本为“无活动”的任何行
目前正在使用:
With Cells
.FormatConditions.Add Type:=xlExpression, Formula1:= _
"=($J1=""No Activity"")"
With .FormatConditions(.FormatConditions.Count)
.SetFirstPriority
With .Interior
.PatternColorIndex = xlAutomatic
.Color = 7405514
.TintAndShade = 0
End With
StopIfTrue = False
End With
End With
......效果很好。使用谷歌搜索和最初给我的录音清理上面的内容:
Cells.Select
Selection.FormatConditions.Add Type:=xlExpression, Formula1:= _
"=($N1=""No Activity"")"
Selection.FormatConditions(Selection.FormatConditions.Count).SetFirstPriority
With Selection.FormatConditions(1).Interior
.PatternColorIndex = xlAutomatic
.ThemeColor = xlThemeColorAccent4
.TintAndShade = 0.599963377788629
End With
Selection.FormatConditions(1).StopIfTrue = False
所以我感到非常自豪和有成就... 但我还要突出显示列J(上面的)中的单元格所包含的行<(不同颜色)“引用”在单元格文本的任何位置。
当我录制一个宏作为条件格式时,它并没有真正为我澄清任何事情:(好吧,它让它变得更糟)
Selection.FormatConditions.Add Type:=xlTextString, String:="Quote", _
TextOperator:=xlContains
Selection.FormatConditions(Selection.FormatConditions.Count).SetFirstPriority
With Selection.FormatConditions(1).Interior
.PatternColorIndex = xlAutomatic
.ThemeColor = xlThemeColorAccent1
.TintAndShade = 0.399945066682943
End With
Selection.FormatConditions(1).StopIfTrue = False
我只是没有抓住它应该如何改变
Type:=xlExpression, Formula1:= _
"=($J1=""No Activity"")"
非常感谢所有想法!
答案 0 :(得分:3)
这适用于Excel 2010:
With Cells
.FormatConditions.Add Type:=xlExpression, Formula1:= _
"=($J1=""No Activity"")"
With .FormatConditions(.FormatConditions.Count)
.SetFirstPriority
With .Interior
.PatternColorIndex = xlAutomatic
.Color = 7405514
.TintAndShade = 0
End With
StopIfTrue = False
End With
.FormatConditions.Add Type:=xlExpression, Formula1:= _
"=ISNUMBER(SEARCH(""*quote*"",$J1))"
With .FormatConditions(.FormatConditions.Count)
.SetFirstPriority
With .Interior
.PatternColorIndex = xlAutomatic
.Color = 4405514
.TintAndShade = 0
End With
StopIfTrue = False
End With
End With
显然,你需要更改第二个FormatConditions.Add
部分的颜色。
编辑:意识到你在单元格的任何地方都在寻找“引用”,所以我更新了原始发布的代码。