Multiple criteria for conditional formatting in Excel
11 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
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 comentarios
Respuestas (0)
Ver también
Categorías
Más información sobre Data Import from MATLAB en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!