日期:2014-05-18 浏览次数:20731 次
Selection.FormatConditions.Add Type:=xlExpression, Formula1:= _"=SUMPRODUCT(($B$7:$B$100=$B7)*($C$7:$C$100=$C7)*($D$7:$D$100=$D7))>1" Selection.FormatConditions(Selection.FormatConditions.Count).SetFirstPriority With Selection.FormatConditions(1).Interior .PatternColorIndex = xlAutomatic .Color = 10066431 .TintAndShade = 0 End With Selection.FormatConditions(1).StopIfTrue = False End Sub
using Excel = Microsoft.Office.Interop.Excel; ... object mis = Type.Missing; Excel.FormatCondition cond = (Excel.FormatCondition)range.FormatConditions.Add(Excel.XlFormatConditionType.xlCellValue, Excel.XlFormatConditionOperator.xlEqual, "=SUMPRODUCT(($B$7:$B$100=$B7)*($C$7:$C$100=$C7)*($D$7:$D$100=$D7))>1", mis, mis, mis, mis, mis); cond.Interior.PatternColorIndex = Excel.Constants.xlAutomatic; cond.Interior.TintAndShade = 0; cond.Interior.Color = ColorTranslator.ToWin32(Color.White); cond.StopIfTrue = false;