How to apply conditional formatting of a cell in excel based on value in another cell using matlab?
4 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
I am trying to automate conditional formatting in excel sheets generated using matlab. I have to format the color of a cell based on the value in the adjacent cell.
For example: I need to format the color of cells B2:B20 based on values from cells A2:A20.
This is the code I am using
Excel = actxserver('Excel.Application');
set(Excel,'Visible',0); Workbook = invoke(Excel.Workbooks, 'open', [fpath filesep file ext]);
sheet = get(Excel.Worksheets, 'Item',sheetname); invoke(sheet,'Activate');
%% range: cells that need to be formatted %% range1: cells that determine the formatting of range
ExAct = Excel.Activesheet; ExActRange = get(ExAct,'Range',range); ExActRange.Select;
xlExpression = 2; Excel.Selection.FormatConditions.Delete; Excel.Selection.FormatConditions.Add(xlExpression, [], ['=' range '=if(range1 = 6, 1)']); Excel.Selection.FormatConditions.Item(1).Interior.ColorIndex = 3;
invoke(Workbook, 'Save'); invoke(Excel, 'Quit'); delete(Excel);
Please let me know my mistake, and better if you could suggest an alternative that could get my job done.
Thanks
Bhaskar
0 comentarios
Respuestas (0)
Ver también
Categorías
Más información sobre Spreadsheets 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!