用宏录制的条件格式很繁杂,以下是几个简化的实例 案例一 :'正红负绿 Union(Range(Cells(2, 17), Cells(row2 - 1 + y, 17)), Range(Cells(2, 19), Cells(row2 - 1 + y, 19))).Select With Selection .FormatConditions.Add Type:=xlCellValue, Operator:=xlGreater, Formula1:="=0" .FormatConditions(1).Font.Color = -16776961 .FormatConditions.Add Type:=xlCellValue, Operator:=xlLess, Formula1:="=0" .FormatConditions(2).Font.Color = -11489280 End With 案例二: '红B绿S Columns("R:R").Select With Selection .FormatConditions.Add Type:=xlCellValue, Operator:=xlEqual, Formula1:=B""" .FormatConditions(1).Font.Color = -16383844 .FormatConditions(1).Interior.Color = 13551615 .FormatConditions.Add Type:=xlCellValue, Operator:=xlEqual, Formula1:=S""" .FormatConditions(2).Font.Color = -16752384 .FormatConditions(2).Interior.Color = 13561798 End With 案例三: Range(Cells(2, 3), Cells(row1, 3)).Select Selection.FormatConditions.AddTop10 With Selection.FormatConditions(1) .TopBottom = xlTop10Top .Rank = 4 '前4红色 .Font.Color = -16383844 .Interior.Color = 13551615 End With Selection.FormatConditions.AddTop10 With Selection.FormatConditions(2) .TopBottom = xlTop10Bottom .Rank = 4 '后4绿色 .Font.Color = -16752384 .Interior.Color = 13561798 End With 案例四: Range("U2:U18").Select Selection.FormatConditions.Add Type:=xlExpression, Formula1:="=and(U2>$W$1,C2<140,right(B2,1)<>""!"")" '三条件公式 Selection.FormatConditions(1).Font.Color = -16383844 Selection.FormatConditions(1).Interior.Color = 10284031 案例五:起始行为变量 Range("B2:B10").Select Selection.FormatConditions.Add Type:=xlExpression, Formula1:="=and(U2>$W$1,AA2>0,k2<0.5)" Selection.FormatConditions(1).Font.Color = -16776961 '红字 Range(Cells(cgs + 2, "B"), Cells(30, "B")).Select Selection.FormatConditions.Add Type:=xlExpression, Formula1:="=or(BB" & cgs + 2 & ">13,BB" & cgs + 2 & "=0)" Selection.FormatConditions(2).Interior.Color = 65535 '黄底 |
|
来自: 新用户7567z8wq > 《我的记录》