Multiple criteria for conditional formatting in Excel
11 ビュー (過去 30 日間)
古いコメントを表示
I want to apply three conditional formats on a cell in Excel. The the first two work, but the third does not. While the condition is in Excel (i.e. there are three conditions), no formatting rules have been applied to the last condition - the colour overwrites one of the first two criteria. How do I add a third conditional format condition? The code is provided below:
% Conditional formatting, only able to put two criteria
hExcel = actxserver('Excel.Application');
hWorkbook = hExcel.Workbooks.Open(filename);
hRange = hExcel.Range(FormatRange);
hRange.FormatConditions.Delete();
xlExpression = 2;
hRange.FormatConditions.Add(xlExpression, [], sprintf('=IF(ABS(%s)>=%d,IF(ABS(%s)<%d,1,0),0)', FormatRange,Crit*0.75,FormatRange,Crit));
hRange.FormatConditions.Item(1).SetFirstPriority();
hRange.FormatConditions.Item(1).Interior.ColorIndex = 45;
hRange.FormatConditions.Add(xlExpression, [], sprintf('=IF(ABS(%s)>=%d,1,0)',FormatRange,Crit));
hRange.FormatConditions.Item(1).SetLastPriority();
hRange.FormatConditions.Item(1).Interior.ColorIndex = 3;
hRange.FormatConditions.Add(xlExpression, [], sprintf('=IF(ABS(%s)<%d,1,0)', FormatRange,Crit*0.75));
hRange.FormatConditions.Item(1).SetLastPriority();
hRange.FormatConditions.Item(1).Interior.ColorIndex = 43;
0 件のコメント
回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Data Import from MATLAB についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!