Multiple criteria for conditional formatting in Excel
12 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
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 Kommentare
Antworten (0)
Siehe auch
Kategorien
Mehr zu Data Import from MATLAB finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!