Hy.我试图根据另一个区域中单元格的值来设置区域中单元格的格式。如果单元格F18:Q18的值大于5%,我希望单元格F8:Q8为红色。如果F8-F18〉5%,F8应为红色,如果G8-G18〉5%,G8应为红色,依此类推,直到Q8。我使用的代码是:
Range("F8:Q8").Select
Application.CutCopyMode = False
Selection.FormatConditions.Add Type:=xlExpression, Formula1:= _
"=ABS(F$18-F$8)>5%"
Selection.FormatConditions(Selection.FormatConditions.Count).SetFirstPriority
With Selection.FormatConditions(1).Font
.Bold = True
.Italic = False
.TintAndShade = 0
End With
With Selection.FormatConditions(1).Interior
.PatternColorIndex = xlAutomatic
.Color = 255
.TintAndShade = 0
End With
Selection.FormatConditions(1).StopIfTrue = False
Selection.FormatConditions(1).ScopeType = xlSelectionScope
但这只使F8变红,而不是整个范围。你能帮我吗
1条答案
按热度按时间xdnvmnnf1#